Performs filtering of annotations by the requested class name

@param array $annotations
@return array
189503
protected function filterContractAnnotation(array $annotations): array
    {
        $contractAnnotations = [];

        foreach ($annotations as $annotation) {
            $annotationClass = \get_class($annotation);

            if (\in_array($annotationClass, $this->expectedAnnotationTypes, true)) {
                $contractAnnotations[] = $annotation;
            }
        }

        return $contractAnnotations;
    }
375867
public static function getPropertiesAnnotations($className, $annotationClassName = null)
    {
        if(null === $annotationClassName)
        {
            return static::$annotations[$className]['Properties'] ?? [];
        }
        $result = [];
        foreach(static::$annotations[$className]['Properties'] ?? [] as $propertyName => $annotations)
        {
            foreach($annotations as $annotation)
            {
                if($annotation instanceof $annotationClassName)
                {
                    $result[$propertyName][] = $annotation;
                }
            }
        }
        return $result;
    }
43197
public function replace(array $annotations) {
		$this->annotations = $annotations;
		$this->names = [];
		$index = 0;
		
		foreach ($annotations as $annotation) {
			$name = $annotation->getName();
			if (!array_key_exists($name, $this->names)) {
				$this->names[$name] = [];
			}
			$this->names[$name][] = $index++;
		}
	}
994142
public function get($entity, $annotation)
    {
        $properties = $this->getProperties($entity);

        $return = array();
        foreach ($properties as $reflectionProperty) {
            $propertyAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, $annotation);
            if (!is_null($propertyAnnotation) && get_class($propertyAnnotation) == $annotation) {
                $return[$reflectionProperty->name] = $reflectionProperty;
            }
        }

        return $return;
    }
901187
public function getClassAnnotations($className, $annotationClassName = null)
    {
        $className = $this->prepareClassReflectionForUsage($className);

        $annotationClassName = $annotationClassName === null ? null : $this->cleanClassName($annotationClassName);
        if (!isset($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS])) {
            return [];
        }
        if ($annotationClassName === null) {
            return $this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS];
        }

        $annotations = [];
        foreach ($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS] as $annotation) {
            if ($annotation instanceof $annotationClassName) {
                $annotations[] = $annotation;
            }
        }

        return $annotations;
    }
722866
public function getFieldAnnotationsNotContainingTags($tags = array()) {
        $matchingAnnotations = array();
        foreach ($this->getFieldAnnotations() as $field => $fieldAnnotations) {

            $fieldAnnotationKeys = array_keys($fieldAnnotations);
            if (!array_intersect($fieldAnnotationKeys, $tags)) {
                $matchingAnnotations[$field] = $fieldAnnotations;
            }
        }

        return $matchingAnnotations;
    }
777796
public function filter(array $locales)
    {
        $this->filtered = [];

        foreach ($locales as $locale) {
            $this->filterLocale($locale);
        }

        return $this->filtered;
    }
1301044
public function getAnnotations()
    {
        $result = array();
        foreach ($this->annotationsDefinitions as $annotationDefinition) {
            $result = array_merge($result, $this->buildAnnotationsInstances($annotationDefinition));
        }

        return $result;
    }
904380
protected function getClassesTaggedWith(array $tags)
    {
        $classes = [];

        foreach ($this->state->annotations as $annotation) {
            if (!$annotation instanceof Tag || !in_array($annotation->value, $tags, true)) {
                continue;
            }

            $classes[] = $annotation->originClass;
        }

        return $classes;
    }
1122989
private function getReturnsFromAnnotation(?Annotation $annotation): array
    {
        return $this->isFilledReturnAnnotation($annotation)
            ? explode('|', preg_split('~\\s+~', $annotation->getContent())[0])
            : [];
    }
39785
public static function getMethodAnnotations($className, $methodName, $annotationClassName = null)
    {
        if(!isset(static::$annotations[$className]['Methods'][$methodName]))
        {
            return [];
        }
        if(null === $annotationClassName)
        {
            return static::$annotations[$className]['Methods'][$methodName];
        }
        else
        {
            $result = [];
            foreach(static::$annotations[$className]['Methods'][$methodName] as $annotation)
            {
                if($annotation instanceof $annotationClassName)
                {
                    $result[] = $annotation;
                }
            }
            return $result;
        }
    }
767093
public function matches($url, array $annotations)
	{
		foreach ( $annotations as $annotation ) {
			if ( $this->matchComponent($annotation, $url) ) {
				return true;
			}
		}

		return false;
	}
1299765
protected function loadClassAnnotations()
    {
        if (empty($this->targetClass)) {
            throw new \RuntimeException("Runtime Error: Any class was defined as target to annotations handling.");
        }

        $annotationsObjects = array();
        $this->annotations['_class_'] = $this->getClassAnnotationsObjects($this->targetClass);
    }
1288600
protected function isInAnnotation(array $exception, array $annotations): bool
    {
        foreach ($annotations as $annotation) {
            if ($exception['class'] === $annotation['class']) {
                return true;
            }
        }

        return false;
    }
730775
public function compile(array $classNames) : array
    {
        $result = [];

        foreach ($classNames as $className) {
            $reflectionClass = new \ReflectionClass($className);

            $prefixPath = '';
            $prefixRegexp = '';
            $classParameterNames = [];

            foreach ($this->annotationReader->getClassAnnotations($reflectionClass) as $annotation) {
                if ($annotation instanceof Route) {
                    $prefixPath = $annotation->path;
                    [$prefixRegexp, $classParameterNames] = $this->processAnnotation($annotation);

                    break;
                }
            }

            foreach ($reflectionClass->getMethods() as $reflectionMethod) {
                $methodName = $reflectionMethod->getName();

                foreach ($this->annotationReader->getMethodAnnotations($reflectionMethod) as $annotation) {
                    if ($annotation instanceof Route) {
                        [$regexp, $methodParameterNames] = $this->processAnnotation($annotation);

                        $pathRegexp = '/^' . $prefixRegexp . $regexp . '$/';
                        $httpMethods = $annotation->methods;

                        if (! $httpMethods) {
                            $httpMethods = $this->defaultMethods;
                        }

                        $this->routes[] = [
                            $prefixPath . $annotation->path,
                            $annotation->methods,
                            $className,
                            $methodName
                        ];

                        $result[] = [
                            $pathRegexp,
                            $httpMethods,
                            $className,
                            $methodName,
                            $classParameterNames,
                            $methodParameterNames
                        ];
                    }
                }
            }
        }

        // Sort routes by path & methods
        sort($this->routes);

        return $result;
    }
1300487
public function matches($url, array $annotations)
	{
		foreach ( $annotations as $annotation ) {
			if ( preg_match($annotation->regexp, $url) ) {
				return true;
			}
		}

		return false;
	}
484864
protected function annotationToArray($annotation)
    {
        $options = array();
        foreach ((array) $annotation as $key => $value) {
            if ($value !== null) {
                $options[$key] = $value;
            }
        }

        return $options;
    }