/** * {@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()); } }
/** * {@inheritdoc} * @throws ParameterDefinitionAlreadyExistsException * @throws ReferenceNotImplementsException * @throws MethodDefinitionNotFoundException * @throws ParameterDefinitionNotFoundException * @throws \InvalidArgumentException */ public function analyze(DefinitionAnalyzer $analyzer, ClassDefinition $classDefinition, \ReflectionParameter $reflectionParameter) { $methodName = $reflectionParameter->getDeclaringFunction()->getName(); $parameterName = $reflectionParameter->getName(); // Define parameter only if method definition is available if ($classDefinition->hasMethod($methodName)) { $methodDefinition = $classDefinition->getMethod($methodName); // Define parameter definition if not exists $parameterDefinition = $methodDefinition->setupParameter($parameterName); $this->setReflectionMetadata($parameterDefinition, $reflectionParameter); $dependency = $parameterDefinition->getDependency(); // If dependency was not set // UndefinedReference is the default value of dependency which was not use before if (!$dependency || $dependency instanceof UndefinedReference) { $this->setDependencyByReflection($parameterDefinition, $reflectionParameter); } $this->setOrderArguments($methodDefinition, $reflectionParameter->getDeclaringFunction()); } }