@param \Reflector $reflectionMethod

@throws

@return array
960120
public function extract(\Reflector $reflectionMethod)
    {
        if (!$reflectionMethod instanceof \ReflectionMethod) {
            throw new ExtractorException(\ReflectionMethod::class, $reflectionMethod);
        }

        return $this->reader->getMethodAnnotations($reflectionMethod);
    }
141843
private function getMethodParameters(string $class, string $methodName) : array
    {
        $methodReflection = new ReflectionMethod($class, $methodName);
        $parametersName   = [];

        foreach ($methodReflection->getParameters() as $parameter) {
            $parametersName[] = $parameter->name;
        }

        return $parametersName;
    }
943560
public function loadDependenciesByReflectionMethod(ReflectionMethod $reflectionMethod)
    {

        // initialize the array for the dependencies
        $dependencies = array();

        // load the object manager instance
        /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */
        $objectManager = $this->getNamingDirectory()->search(
            sprintf('php:global/%s/%s', $this->getApplication()->getUniqueName(), ObjectManagerInterface::IDENTIFIER)
        );

        // iterate over the constructor parameters
        /** @var \AppserverIo\Lang\Reflection\ParameterInterface $reflectionParameter */
        foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
            $dependencies[] = $this->get($objectManager->getPreference($reflectionParameter->getType()));
        }

        // return the initialized dependencies
        return $dependencies;
    }
633451
private function generateMethodCode(\ReflectionMethod $rm) : array
    {
        $method_name     = $rm->getName();
        $modifiers       = $rm->getModifiers();
        $params          = $rm->getParameters();
        $has_return_type = $rm->hasReturnType();
        $return_type     = $rm->getReturnType();
        
        $is_static = Util::isAllBitSet($modifiers, \ReflectionMethod::IS_STATIC);
        
        // method body
        $method_body = '';
        if ($has_return_type){
            // pseudo code with return value
            $method_body .= 'return ' . self::generatePseudoReturnCode($return_type) . ';';
        }
    
        // generate code
        $parameters_code = [];
        foreach($params as $rp){
            $parameters_code[] = self::generateParameterPrototypeCode($rp);
        }
        $parameters_code = implode(', ', $parameters_code);
        
        $return_type_part = '';
        if ($has_return_type){
            $return_type_part .= ' : ';
            $return_type_part .= self::generateReturnTypeCode($return_type);
        }
        
        $prototype = Code::PHP_PUBLIC . ' ' . ($is_static ? Code::PHP_STATIC . ' ' : '') . Code::PHP_FUNCTION . ' '
                        . $method_name . '(' . $parameters_code . ')' . $return_type_part;
        
        $code[] = Code::INDENT . $prototype;
        $code[] = Code::INDENT . '{';
        if (!empty($method_body)){
            $code[] = Code::INDENT . Code::INDENT . $method_body;
        }
        $code[] = Code::INDENT . '}';
        
        return $code;
    }
1369886
protected function getCmsDocBlockTags(ReflectionMethod $method)
    {
        if ( ! ($docBlock = $method->getDocComment())) {
            return [];
        }

        $factory = DocBlockFactory::createInstance();
        $doc     = $factory->create( $docBlock );

        $tags = $doc->getTagsByName('cms');

        if ( ! $tags || ! count($tags)) {
            return [];
        }

        $cmsTags = [];

        foreach ($tags as $tag) {

            if ( ! method_exists($tag, 'getDescription')) {
                // @codeCoverageIgnoreStart
                continue;
                // @codeCoverageIgnoreEnd
            }

            $description = trim($tag->getDescription());

            if (preg_match('#\s+#', $description)) {
                list($firstWord, $parameters) = preg_split('#\s+#', $description, 2);
            } else {
                $firstWord  = $description;
                $parameters = '';
            }

            $firstWord = strtolower($firstWord);

            if ($firstWord == 'relation') {
                $cmsTags['relation'] = true;
                continue;
            }

            if ($firstWord == 'ignore') {
                $cmsTags['ignore'] = true;
                continue;
            }

            if ($firstWord == 'morph') {
                if ( ! $parameters) continue;

                $models = array_map('trim', explode(',', $parameters));

                if ( ! array_key_exists('morph', $cmsTags)) {
                    $cmsTags['morph'] = [];
                }

                $cmsTags['morph'] = array_merge($cmsTags['morph'], $models);
                $cmsTags['morph'] = array_unique($cmsTags['morph']);
                continue;
            }
        }

        return $cmsTags;
    }
457142
protected function buildMethod(ReflectionMethod $reflectionMethod) : Node\Stmt\ClassMethod
    {
        $methodBuilder = new Method($reflectionMethod->getName());

        if ($reflectionMethod->isPublic()) {
            $methodBuilder->makePublic();
        }

        if ($reflectionMethod->isProtected()) {
            $methodBuilder->makeProtected();
        }

        if ($reflectionMethod->isPrivate()) {
            $methodBuilder->makePrivate();
        }

        if ($reflectionMethod->isStatic()) {
            $methodBuilder->makeStatic();
        }

        if ($reflectionMethod->isAbstract()) {
            $methodBuilder->makeAbstract();
        }

        if ($reflectionMethod->isFinal()) {
            $methodBuilder->makeFinal();
        }

        if ($reflectionMethod->returnsReference()) {
            $methodBuilder->makeReturnByRef();
        }

        foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
            $methodBuilder->addParam($this->buildParameter($reflectionParameter));
        }

        // @todo should parse method body if possible (skipped for now)

        return $methodBuilder->getNode();
    }
700098
protected function getClassMeta(ReflectionClass $reflection): array
    {
        $doc = $reflection->getDocComment();
        $notations = $this->parser->parse($doc);

        return $notations;
    }
404984
public function getRunnerByMethod(\ReflectionMethod $method)
    {
        $class = new \ReflectionClass($method->class);
        $className = $class->name;

        if (!array_key_exists($className, $this->runnerMappings)) {
            return;
        }

        $methodName = $method->name;
        if (!array_key_exists($methodName, $this->runnerMappings[$className])) {
            return;
        }

        return $this->runnerMappings[$className][$methodName];
    }
279008
public function getRoutableReflectionMethodList()
    {
        $reflections = [];

        foreach ($this->getReflection()->getMethods() as $reflection) {

            if ($this->isValidMethod($reflection->name)) {

                $reflections[] = $reflection;
            }
        }

        return $reflections;
    }
20904
private function resolveMethodDependencies(\ReflectionFunctionAbstract $reflector)
    {
        $parameters = [];
        foreach ($reflector->getParameters() as $key => $parameter) {
            $class = $parameter->getClass();
            if ($class) {
                //Request
                $instance = app()->make($class->name);

                if ($instance instanceof FormRequest) {
                    if ($instance->authorize()) {
                        $instance->validate();
                    } else {
                        $instance->forbiddenResponse();
                    }
                }

                array_splice(
                    $parameters, $key, 0, [$instance]
                );
            }
        }

        return $parameters;
    }
463671
public static function extractProperties(\ReflectionClass $reflector, $type = \ReflectionProperty::IS_PROTECTED, $pattern = self::INJECTABLE_PATTERN)
    {
        $properties = [];
        foreach ($reflector->getProperties($type) as $property) {
            $doc = $property->getDocComment();
            if (preg_match($pattern, $doc)) {
                $instanceType = self::extractVarType($property->getDocComment());
                if (null !== $instanceType) {
                    $properties[$property->getName()] = $instanceType;
                }
            }
        }
        return $properties;
    }
401844
public function extractReflectionMethodInfo(\ReflectionMethod $method)
    {
        $method_name = strtolower($method->getName());

        $class_storage = $this->storage_provider->get($method->class);

        if (isset($class_storage->methods[strtolower($method_name)])) {
            return;
        }

        $method_id = $method->class . '::' . $method_name;

        $storage = $class_storage->methods[strtolower($method_name)] = new MethodStorage();

        $storage->cased_name = $method->name;
        $storage->defining_fqcln = $method->class;

        if (strtolower((string)$method->name) === strtolower((string)$method->class)) {
            $this->codebase->methods->setDeclaringMethodId(
                $method->class . '::__construct',
                $method->class . '::' . $method_name
            );
            $this->codebase->methods->setAppearingMethodId(
                $method->class . '::__construct',
                $method->class . '::' . $method_name
            );
        }

        $declaring_class = $method->getDeclaringClass();

        $storage->is_static = $method->isStatic();
        $storage->abstract = $method->isAbstract();

        $class_storage->declaring_method_ids[$method_name] =
            $declaring_class->name . '::' . strtolower((string)$method->getName());

        $class_storage->inheritable_method_ids[$method_name] = $class_storage->declaring_method_ids[$method_name];
        $class_storage->appearing_method_ids[$method_name] = $class_storage->declaring_method_ids[$method_name];
        $class_storage->overridden_method_ids[$method_name] = [];

        try {
            $storage->return_type = CallMap::getReturnTypeFromCallMap($method_id);
            $storage->return_type->queueClassLikesForScanning($this->codebase);
        } catch (\InvalidArgumentException $e) {
            // do nothing
        }

        $storage->visibility = $method->isPrivate()
            ? ClassLikeAnalyzer::VISIBILITY_PRIVATE
            : ($method->isProtected() ? ClassLikeAnalyzer::VISIBILITY_PROTECTED : ClassLikeAnalyzer::VISIBILITY_PUBLIC);

        $possible_params = CallMap::getParamsFromCallMap($method_id);

        if ($possible_params === null) {
            $params = $method->getParameters();

            $storage->params = [];

            /** @var \ReflectionParameter $param */
            foreach ($params as $param) {
                $param_array = $this->getReflectionParamData($param);
                $storage->params[] = $param_array;
                $storage->param_types[$param->name] = $param_array->type;
            }
        } else {
            foreach ($possible_params[0] as $param) {
                if ($param->type) {
                    $param->type->queueClassLikesForScanning($this->codebase);
                }
            }

            $storage->params = $possible_params[0];
        }

        $storage->required_param_count = 0;

        foreach ($storage->params as $i => $param) {
            if (!$param->is_optional && !$param->is_variadic) {
                $storage->required_param_count = $i + 1;
            }
        }
    }
1298640
public function getRules(Reflector $reflection): array
    {
        if ($reflection instanceof ReflectionMethod) {
            $key = $reflection->getDeclaringClass()->getName().'::'.$reflection->getName();
        } elseif ($reflection instanceof ReflectionClass) {
            $key = $reflection->getName();
        } elseif ($reflection instanceof ReflectionProperty) {
            $key = $reflection->getDeclaringClass()->getName().'::$'.$reflection->getName();
        } else {
            throw new InvalidArgumentException('Reflection must be an instance of either ReflectionMethod, ReflectionClass or ReflectionProperty.');
        }

        if (!isset($this->cache[$key])) {
            $this->cache[$key] = $this->ruleProvider->getRules($reflection);
        }

        return $this->cache[$key];
    }
1220107
public static function extractReflectionParams($sr, \ReflectionMethod $method)
    {
        $regex = $sr[1] ?: $sr[0];
        $default = '';
        $params = [];
        $parameters = $method->getParameters();
        $requirements = [];
        /** @var \ReflectionParameter $param */
        if (count($parameters) > 0) {
            foreach ($parameters as $param) {
                if ($param->isOptional() && !is_array($param->getDefaultValue())) {
                    $params[$param->getName()] = $param->getDefaultValue();
                    $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex);
                } elseif(!$param->isOptional()) {
                    $requirements[] = $param->getName();
                }
            }
        } else {
            $default = $regex;
        }

        return [$regex, $default, $params, $requirements];
    }
1346832
private function getProxyMethods(): array
    {
        if (null !== $this->reflectionProxyMethods) {
            return $this->reflectionProxyMethods;
        }

        $proxyMethods = [];
        $methods = $this->getClassMethods();

        foreach ($methods as $method) {
            $docComment = $method->getDocComment();

            if (\strpos($docComment, 'Transactional') !== false) {
                $annotation = $this->annotationReader->getMethodAnnotation(
                    $method,
                    Transactional::class
                );

                if ($annotation) {
                    $proxyMethods[] = $method;
                }
            }
        }

        $this->reflectionProxyMethods = $proxyMethods;

        return $proxyMethods;
    }
99609
private function getMethodArguments(\ReflectionMethod $method)
    {
        // ignore all query params
        $params = $this->paramReader->getParamsFromMethod($method);

        // check if a parameter is coming from the request body
        $ignoreParameters = [];
        if (class_exists(ParamConverter::class)) {
            $ignoreParameters = array_map(function ($annotation) {
                return
                    $annotation instanceof ParamConverter &&
                    'fos_rest.request_body' === $annotation->getConverter()
                        ? $annotation->getName() : null;
            }, $this->annotationReader->getMethodAnnotations($method));
        }

        // ignore several type hinted arguments
        $ignoreClasses = [
            Request::class,
            ParamFetcherInterface::class,
            ConstraintViolationListInterface::class,
            ParamConverter::class,
            MessageInterface::class,
        ];

        $arguments = [];
        foreach ($method->getParameters() as $argument) {
            if (isset($params[$argument->getName()])) {
                continue;
            }

            $argumentClass = $argument->getClass();
            if ($argumentClass) {
                $className = $argumentClass->getName();
                foreach ($ignoreClasses as $class) {
                    if ($className === $class || is_subclass_of($className, $class)) {
                        continue 2;
                    }
                }
            }

            if (in_array($argument->getName(), $ignoreParameters, true)) {
                continue;
            }

            $arguments[] = $argument;
        }

        return $arguments;
    }
170117
public function getAnnotations(\Reflector $Reflection)
    {
        $doc = $Reflection->getDocComment();
        if ($this->cache) {
            $key = $this->cache->getKey($doc);
            $ast = $this->cache->get($key);
            if (! $ast) {
                $ast = $this->parser->parse($doc);
                $this->cache->set($key, $ast);
            }
        } else {
            $ast = $this->parser->parse($doc);
        }

        return new AnnotationsBag($ast);
    }