/** * {@inheritdoc} * @throws MethodDefinitionAlreadyExistsException */ public function analyze(DefinitionAnalyzer $analyzer, ClassDefinition $classDefinition, \ReflectionMethod $reflectionMethod) { $methodName = $reflectionMethod->getName(); // Resolve annotations $annotations = $this->reader->getMethodAnnotations($reflectionMethod); // Create method definition if annotation is exists if (count($annotations)) { // Define method if not exists if (!$classDefinition->hasMethod($methodName)) { $classDefinition->defineMethod($methodName); } // Exec method annotations foreach ($annotations as $annotation) { if ($annotation instanceof ResolveMethodInterface) { $annotation->resolveMethod($analyzer, $classDefinition, $reflectionMethod); } } } }
/** * Resolve method * * @param ClassDefinition $classDefinition * @param array $methodArray * @param string $methodName * @throws MethodDefinitionAlreadyExistsException * @throws \InvalidArgumentException * @throws ParameterDefinitionAlreadyExistsException * @throws ReferenceNotImplementsException */ protected function resolveMethod(ClassDefinition $classDefinition, array $methodArray, string $methodName) { $methodDefinition = $classDefinition->defineMethod($methodName); if (array_key_exists('arguments', $methodArray)) { $this->resolveArguments($methodDefinition, $methodArray['arguments']); } }