Asserts that required annotations are present.

@param array $annotations Annotations to test.

@return void

@throws AnnotationException Thrown if none or wrong annotations given.
345825
protected function assertAnnotationClass(array $annotations)
	{
		if ( !$annotations ) {
			$parameters = array((string)$this->property, $this->property->getDataType());
			$message = '@find-by must be specified in the property "%s" DocBlock or in class "%s" DocBlock';
			throw new AnnotationException(vsprintf($message, $parameters), AnnotationException::TYPE_REQUIRED);
		}

		foreach ( $annotations as $annotation ) {
			if ( !($annotation instanceof FindByAnnotation) ) {
				$parameters = array((string)$this->property, $this->property->getDataType());
				$message = '@find-by must be specified in the property "%s" DocBlock or in class "%s" DocBlock';
				throw new AnnotationException(vsprintf($message, $parameters), AnnotationException::TYPE_REQUIRED);
			}
		}
	}
504039
public function matches($url, array $annotations)
	{
		foreach ( $annotations as $annotation ) {
			if ( $url === $annotation->url ) {
				return true;
			}
		}

		return false;
	}
1224418
private function validateAnnotations()
    {
        //Count annotations in the annotation namespace, ignore annotations not in our namespace
        $count = 0;
        foreach($this->annotations as $a)
        {
            //If you find the namespace in the class name, add to count
            if(strrpos(get_class($a), self::ANNOTATION_NAMESPACE) !== false)
            {
                $count++;
            }
        }

        switch($count)
        {
            //0 annotations, just ignore
            case 0:

                return;

            //1 Annotation, it can't be index.
            case 1:

                if($this->getAnnotationIndex(self::INDEX) < 0)
                {
                    //It's not index, return.
                    return;
                }

                throw new Exception("@Index cannot be the only annotation on {$this->name} in {$this->property->getDeclaringClass()->getName()}.");

            //2 Annotations, they have to be index and property.
            case 2:

                if( ($this->getAnnotationIndex(self::PROPERTY) >= 0) && ($this->getAnnotationIndex(self::INDEX) >= 0))
                {
                    //They are index and property, return
                    return;
                }

                break;
        }

        //It didn't fall into any of the categories, must be invalid
        throw new Exception("Invalid annotation combination on {$this->name} in {$this->property->getDeclaringClass()->getName()}.");
    }
710018
protected function requireClasses(array $classes)
    {
        if ($this->loadClasses) {
            foreach ($classes as $classpath => $classname) {
                if (class_exists($classname)) {
                    continue;
                }

                require_once "$classpath";
            }
        }
    }
308666
private function parseAnnotations($annotations)
    {
        // parse array from (numeric key => 'annotation <value>') to (annotation => value)
        $methodServices = [];
        foreach ($annotations as $annotation) {
            if (!preg_match('/^(\w+)\s+\$(\w+)\s+([\w\.\@\%]+)/', $annotation, $matches)) {
                continue;
            }

            array_shift($matches);
            $tag = array_shift($matches);
            if ($tag == self::SERVICE_DOC_TAG) {
                list($argument, $service) = $matches;
                $methodServices[$argument] = $service;
            }
        }

        return $methodServices;
    }
444611
private function filterAnnotations(array $annotations): array
    {
        $annotations = \array_filter($annotations, function ($annotation) {
            $ref = new \ReflectionObject($annotation);

            return 0 === \mb_strpos($ref->getNamespaceName(), 'TSantos\Serializer');
        });

        return $annotations;
    }
859505
public function validate($inputs)
    {
        if (empty($this->rules)) {
            throw new \RuntimeException('You must set rules for validator.');
            return false;
        }

        if (empty($inputs)) {
            throw new \RuntimeException('Empty array passed to validate method');
        }

        $this->validator($inputs)->addRule();

        if (!$this->run()) {
            $this->setErrors($this->validation->getErrors());

            return false;
        }

        return true;
    }
48584
public function doesDocBlockContainAnnotation(string $annotation): bool
    {
        $docComment = (new \ReflectionClass($this->fullClassName))->getDocComment();

        if (false === $docComment) {
            return false;
        }

        return false !== strpos($docComment, $annotation);
    }
673949
public function setup(array $formatters)
    {
        foreach ($formatters as $formatterName => $formatter) {
            if (!$formatter instanceof TrackingParameterFormatterInterface) {
                throw new InvalidConfigurationException(
                    sprintf('Invalid tracking parameter formatter "%s".', $formatterName)
                );
            }
        }

        $this->formatters = $formatters;
    }
361884
private boolean checkAnnotations(List<? extends AnnotationTree> annotations, Tree node) {
    for (AnnotationTree annotation : annotations) {
      if (isJ2ObjCIncompatible(annotation)) {
        nodesToStrip.add(node);
        return false;
      }
    }
    return true;
  }
1270843
protected function scanAnnotations()
    {
        $scans = $this->classesToScan();

        if (empty($scans)) {
            return;
        }

        $scanner = $this->getAnnotationScanner();

        $scanner->setClassesToScan($scans);

        $scanner->scan();
    }
1257248
public function setAnnotation($key, $annotation)
    {
        if (array_key_exists($key, $this->annotations)) {
            $this->annotations[$key] = $annotation;
        }
    }
1290389
protected function validateAttributesToLdap(array $attributes)
    {
        if (!$this->schema) {
            return;
        }
        $missing = [];

        foreach ($this->schema->getRequiredAttributes() as $attribute) {
            if (!array_key_exists(strtolower($attribute), array_change_key_case($attributes))) {
                $missing[] = $attribute;
            }
        }

        if (!empty($missing)) {
            throw new LogicException(
                sprintf('The following required attributes are missing: %s', implode(', ', $missing))
            );
        }
    }
645964
private static function getFirstAnnotationMatching(array $annotations, $annotationClass)
    {
        if (\is_string($annotationClass)) {
            $annotationClass = [$annotationClass];
        }

        foreach ($annotations as $annotation) {
            foreach ($annotationClass as $class) {
                if ($annotation instanceof $class) {
                    return $annotation;
                }
            }
        }

        return false;
    }
769435
public function validateProviders(array $providers) : void
    {
        Assert::allClassExists($providers);
        Assert::allImplementsInterface($providers, self::PROVIDER_INTERFACE);

        foreach ($this->requiredProviders as $name) {
            if (!in_array($name, array_keys($providers))) {
                throw new InvalidArgumentException("Configuration is missing a required provider for [$name]");
            }
        }
    }
303054
protected function setupAnnotationMetadata()
    {
        $annotationFiles = (array) $this->getOption('annotation_files');
        array_walk(
            $annotationFiles,
            function ($file) {
                if (!file_exists($file)) {
                    throw new \RuntimeException(sprintf('"%s" file does not exist', $file));
                }

                AnnotationRegistry::registerFile($file);
            }
        );

        AnnotationRegistry::registerAutoloadNamespaces($this->getAnnotationNamespaces());

        $annotationLoaders = (array) $this->getOption('annotation_autoloaders');
        array_walk(
            $annotationLoaders,
            function ($autoLoader) {
                AnnotationRegistry::registerLoader($autoLoader);
            }
        );
    }
887617
protected function _annotate($path, $content, array $annotations) {
		if (!count($annotations)) {
			return false;
		}

		$file = $this->_getFile($path, $content);

		$phpOpenTagIndex = $file->findNext(T_OPEN_TAG, 0);
		if ($phpOpenTagIndex === false) {
			$phpOpenTagIndex = null;
		}

		$needsPhpTag = $phpOpenTagIndex === null || $this->_needsPhpTag($file, $phpOpenTagIndex);
		$docBlockCloseTagIndex = null;
		if ($needsPhpTag) {
			$phpOpenTagIndex = null;
		} else {
			$docBlockCloseTagIndex = $this->_findExistingDocBlock($file, $phpOpenTagIndex);
		}

		$this->_resetCounter();
		if ($docBlockCloseTagIndex && !$this->isInlineDocBlock($file, $docBlockCloseTagIndex)) {
			$newContent = $this->_appendToExistingDocBlock($file, $docBlockCloseTagIndex, $annotations);
		} else {
			$newContent = $this->_addNewTemplateDocBlock($file, $annotations, $phpOpenTagIndex, $docBlockCloseTagIndex);
		}

		$this->_displayDiff($content, $newContent);
		$this->_storeFile($path, $newContent);

		$this->_report();

		return true;
	}