Reads method annotations.

@param \ReflectionMethod $reflectionMethod
@param string            $annotationName

@return RouteAnnotation[]
165951
private function readMethodAnnotations(\ReflectionMethod $reflectionMethod, $annotationName)
    {
        $annotations = [];
        $annotationClass = "FOS\\RestBundle\\Controller\\Annotations\\$annotationName";

        if ($annotations_new = $this->annotationReader->getMethodAnnotations($reflectionMethod)) {
            foreach ($annotations_new as $annotation) {
                if ($annotation instanceof $annotationClass) {
                    $annotations[] = $annotation;
                }
            }
        }

        return $annotations;
    }
696905
private function getSupportedHttpMethods(ReflectionMethod $refMethod) : array
    {
        $methods = array();

        if ($this->annotationReader->getMethodAnnotation($refMethod, Get::class)) {
            $methods[] = 'GET';
        }
        if ($this->annotationReader->getMethodAnnotation($refMethod, Post::class)) {
            $methods[] = 'POST';
        }
        if ($this->annotationReader->getMethodAnnotation($refMethod, Put::class)) {
            $methods[] = 'PUT';
        }
        if ($this->annotationReader->getMethodAnnotation($refMethod, Delete::class)) {
            $methods[] = 'DELETE';
        }

        return $methods;
    }
73768
private function collectMethodCacheAnnotations(ReflectionMethod $method)
    {
        $annotations = array_filter($this->annotationsReader->getMethodAnnotations($method), function ($annotation) {
            return $annotation instanceof CacheAnnotation;
        });

        return new AnnotationCollection($annotations);
    }
745993
private function getMethodCallbacks(\ReflectionMethod $method)
    {
        $callbacks   = array();
        $annotations = $this->reader->getMethodAnnotations($method);

        foreach ($annotations as $annot) {
            if ($annot instanceof \Doctrine\ORM\Mapping\PrePersist) {
                $callbacks[] = array($method->name, Events::prePersist);
            }

            if ($annot instanceof \Doctrine\ORM\Mapping\PostPersist) {
                $callbacks[] = array($method->name, Events::postPersist);
            }

            if ($annot instanceof \Doctrine\ORM\Mapping\PreUpdate) {
                $callbacks[] = array($method->name, Events::preUpdate);
            }

            if ($annot instanceof \Doctrine\ORM\Mapping\PostUpdate) {
                $callbacks[] = array($method->name, Events::postUpdate);
            }

            if ($annot instanceof \Doctrine\ORM\Mapping\PreRemove) {
                $callbacks[] = array($method->name, Events::preRemove);
            }

            if ($annot instanceof \Doctrine\ORM\Mapping\PostRemove) {
                $callbacks[] = array($method->name, Events::postRemove);
            }

            if ($annot instanceof \Doctrine\ORM\Mapping\PostLoad) {
                $callbacks[] = array($method->name, Events::postLoad);
            }

            if ($annot instanceof \Doctrine\ORM\Mapping\PreFlush) {
                $callbacks[] = array($method->name, Events::preFlush);
            }
        }

        return $callbacks;
    }
292923
public function getMethodAnnotationsForMatchingTag($tag, $methodName = null) {
        if ($methodName) {
            return isset($this->methodAnnotations[$methodName][$tag]) ? $this->methodAnnotations[$methodName][$tag] : array();
        } else {
            $matchingAnnotations = array();
            foreach ($this->getMethodAnnotations() as $method => $methodAnnotations) {
                if (isset($methodAnnotations[$tag])) {
                    $matchingAnnotations[$method] = $methodAnnotations[$tag];
                }
            }

            return $matchingAnnotations;
        }
    }
905805
private function getClassAnnotation($entity, $annotationName)
    {
        $reflectionClass = new \ReflectionClass($entity);

        $annotation = $this->reader->getClassAnnotation($reflectionClass, $annotationName);

        if ($annotation === null && $reflectionClass->getParentClass()) {
            $annotation = $this->reader->getClassAnnotation($reflectionClass->getParentClass(), $annotationName);
        }

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

        return $this->reader->getMethodAnnotations($reflectionMethod);
    }
572487
private function readMethodCallees($class, ReflectionMethod $method)
    {
        $callees = array();

        // read parent annotations
        try {
            $prototype = $method->getPrototype();
            // error occurs on every second PHP stable release - getPrototype() returns itself
            if ($prototype->getDeclaringClass()->getName() !== $method->getDeclaringClass()->getName()) {
                $callees = array_merge($callees, $this->readMethodCallees($class, $prototype));
            }
        } catch (ReflectionException $e) {
        }

        if ($docBlock = $method->getDocComment()) {
            $callees = array_merge($callees, $this->readDocBlockCallees($class, $method, $docBlock));
        }

        return $callees;
    }
743210
public function getMethodAnnotations($method)
    {
        if (!$this->hasMethod($method)) {
            $name = $this->_getReflection()->getName();
            throw new Exception\InvalidArgumentException(
                "The class {$name} doesn't have a property called {$method}"
            );
        }

        if (empty($this->_annotations['methods'][$method])) {
            $comment = $this->_getReflection()
                ->getMethod($method)
                ->getDocComment();
            $data = AnnotationParser::getAnnotations($comment);
            $methodAnnotations = new AnnotationsList();
            foreach ($data as $property => $parsedData) {
                $methodAnnotations->append(
                    $this->_createAnnotation($property, $parsedData)
                );
            }
            $this->_annotations['methods'][$method] = $methodAnnotations;
        }
        return $this->_annotations['methods'][$method];
    }
1360591
public static function readMethod( $method , $annotation = null ) {

		$ref = $method instanceof ReflectionMethod ? $method : new ReflectionMethod( $method[0] , $method[1] );

		return $annotation ? static::reader()->getMethodAnnotation( $ref , $annotation ) : static::reader()->getMethodAnnotations( $ref );

	}
86953
public function processAnnotation(Route $annotation) : array
    {
        $parameterNames = [];

        $regexp = preg_replace_callback('/\{([^\}]+)\}|(.+?)/', function(array $matches) use ($annotation, & $parameterNames) : string {
            if (isset($matches[2])) {
                return preg_quote($matches[2], '/');
            }

            $parameterName = $matches[1];
            $parameterNames[] = $parameterName;

            if (isset($annotation->patterns[$parameterName])) {
                $pattern = $annotation->patterns[$parameterName];
            } else {
                $pattern = '[^\/]+';
            }

            return '(' . $pattern. ')';
        }, $annotation->path);

        foreach ($annotation->patterns as $parameterName => $pattern) {
            if (! in_array($parameterName, $parameterNames, true)) {
                throw new \LogicException(sprintf('Pattern does not match any parameter: "%s".', $parameterName));
            }
        }

        return [$regexp, $parameterNames];
    }
601045
protected function getMethodCode(\ReflectionMethod $reflectionMethod)
    {
        $file = file($reflectionMethod->getFileName());

        $methodCodeLines = array();
        foreach (range($reflectionMethod->getStartLine(), $reflectionMethod->getEndLine() - 1) as $line) {
            $methodCodeLines[] = $file[$line];
        }

        return array_values($methodCodeLines);
    }
861440
protected function getMethodParams(\ReflectionMethod $reflectionMethod, $requestParams)
    {
        $actionParams = [];
        $methodParams = $reflectionMethod->getParameters();

        foreach ($methodParams as $param) {
            $paramName = $param->getName();
            if (!array_key_exists($paramName, $requestParams)) {
                throw new \yii\web\BadRequestHttpException("Not found JSON-RPC request parameter '{$paramName}'.");
            }

            $paramClass = $param->getClass();
            $actionParams[$paramName] = !empty($paramClass) ? $this->getParameterModel($paramName, $paramClass->name, $requestParams) : $requestParams[$paramName];
        }

        return $actionParams;
    }
537437
static function getAnnotation($name, $class, $method = NULL, $nullable = TRUE)
	{
		try {
			NULL === $method or $annotation = self::getMethodAnnotation($method, $name, $class);
			isset($annotation) or $annotation = self::getClassAnnotation($class, $name);
		} catch (ReflectionException $e) {
			$annotation = NULL;
		}

		return !$nullable && NULL === $annotation
			? self::annotationClass($name)
			: $annotation;
	}
918017
private function getParameters(Request $request, \ReflectionFunctionAbstract $controller) : array
    {
        if ($controller instanceof \ReflectionMethod) {
            $annotations = $this->annotationReader->getMethodAnnotations($controller);
        } else {
            // @todo annotation reading on generic functions is not available yet
            return [];
        }

        $parameters = [];
        foreach ($controller->getParameters() as $parameter) {
            $parameters[$parameter->getName()] = $parameter;
        }

        $result = [];

        foreach ($annotations as $annotation) {
            if ($annotation instanceof RequestParam) {
                $result[$annotation->getBindTo()] = $this->getParameter(
                    $annotation,
                    $controller,
                    $parameters,
                    $request
                );
            }
        }

        return $result;
    }
988171
public static function objectsMethodValues(array $objectArray, string $methodName): array
    {
        $methodValues = [];

        foreach ($objectArray as $object) {
            $methodValues[] = $object->$methodName();
        }

        return $methodValues;
    }
756766
protected function processMethod(\ReflectionMethod $method, Definition $definition)
    {
        $annotations = $this->reader->getMethodAnnotations($method);

        foreach ($annotations as $annotation)
        {
            if ($annotation instanceof AttributeAnnotation) {
                $this->validateMethodAttribute($annotation, $method);

                $attribute = $this->createAttributeByMethod($annotation, $method);
                $definition->addAttribute($attribute);
            }
        }
    }