コード例 #1
0
 /**
  * {@inheritdoc}
  * @throws MethodDefinitionAlreadyExistsException
  * @throws MethodDefinitionNotFoundException
  */
 public function analyze(DefinitionAnalyzer $analyzer, ClassDefinition $classDefinition, \ReflectionMethod $reflectionMethod)
 {
     $methodName = $reflectionMethod->getName();
     // Constructor definition is required
     if ($methodName === '__construct' && !$classDefinition->hasMethod('__construct')) {
         $classDefinition->defineConstructor()->end();
     }
     // Set method metadata
     if ($classDefinition->hasMethod($methodName)) {
         $classDefinition->getMethod($methodName)->setModifiers($reflectionMethod->getModifiers())->setIsPublic($reflectionMethod->isPublic());
     }
 }
コード例 #2
0
 /**
  * Resolve constructor
  *
  * @param ClassDefinition $classDefinition
  * @param array $constructorArray
  * @throws MethodDefinitionAlreadyExistsException
  * @throws \InvalidArgumentException
  * @throws ParameterDefinitionAlreadyExistsException
  * @throws ReferenceNotImplementsException
  */
 protected function resolveConstructor(ClassDefinition $classDefinition, array $constructorArray)
 {
     $methodDefinition = $classDefinition->defineConstructor();
     if (array_key_exists('arguments', $constructorArray)) {
         $this->resolveArguments($methodDefinition, $constructorArray['arguments']);
     }
 }
コード例 #3
0
ファイル: CoreLoader.php プロジェクト: samsonos/php_core
 /**
  * Define constructor
  *
  * @param ClassDefinition $classDefinition
  * @param $path
  * @throws MethodDefinitionAlreadyExistsException
  */
 protected function defineConstructor(ClassDefinition $classDefinition, $path)
 {
     $classDefinition->defineConstructor()->defineParameter('path')->defineDependency(new StringReference($path))->end()->end();
 }