diff vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children
line wrap: on
line diff
--- a/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php	Fri Feb 23 15:51:18 2018 +0000
+++ b/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php	Fri Feb 23 15:52:07 2018 +0000
@@ -103,6 +103,15 @@
     );
 
     /**
+     * A list with annotations that are not causing exceptions when not resolved to an annotation class.
+     *
+     * The names are case sensitive.
+     *
+     * @var array
+     */
+    private static $globalIgnoredNamespaces = array();
+
+    /**
      * Add a new annotation to the globally ignored annotation names with regard to exception handling.
      *
      * @param string $name
@@ -113,6 +122,16 @@
     }
 
     /**
+     * Add a new annotation to the globally ignored annotation namespaces with regard to exception handling.
+     *
+     * @param string $namespace
+     */
+    static public function addGlobalIgnoredNamespace($namespace)
+    {
+        self::$globalIgnoredNamespaces[$namespace] = true;
+    }
+
+    /**
      * Annotations parser.
      *
      * @var \Doctrine\Common\Annotations\DocParser
@@ -151,8 +170,10 @@
      * Constructor.
      *
      * Initializes a new AnnotationReader.
+     *
+     * @param DocParser $parser
      */
-    public function __construct()
+    public function __construct(DocParser $parser = null)
     {
         if (extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === "0" || ini_get('opcache.save_comments') === "0")) {
             throw AnnotationException::optimizerPlusSaveComments();
@@ -174,7 +195,8 @@
 
         AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php');
 
-        $this->parser    = new DocParser;
+        $this->parser = $parser ?: new DocParser();
+
         $this->preParser = new DocParser;
 
         $this->preParser->setImports(self::$globalImports);
@@ -191,6 +213,7 @@
         $this->parser->setTarget(Target::TARGET_CLASS);
         $this->parser->setImports($this->getClassImports($class));
         $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
+        $this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
 
         return $this->parser->parse($class->getDocComment(), 'class ' . $class->getName());
     }
@@ -222,6 +245,7 @@
         $this->parser->setTarget(Target::TARGET_PROPERTY);
         $this->parser->setImports($this->getPropertyImports($property));
         $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
+        $this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
 
         return $this->parser->parse($property->getDocComment(), $context);
     }
@@ -253,6 +277,7 @@
         $this->parser->setTarget(Target::TARGET_METHOD);
         $this->parser->setImports($this->getMethodImports($method));
         $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
+        $this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
 
         return $this->parser->parse($method->getDocComment(), $context);
     }
@@ -282,7 +307,8 @@
      */
     private function getIgnoredAnnotationNames(ReflectionClass $class)
     {
-        if (isset($this->ignoredAnnotationNames[$name = $class->getName()])) {
+        $name = $class->getName();
+        if (isset($this->ignoredAnnotationNames[$name])) {
             return $this->ignoredAnnotationNames[$name];
         }
 
@@ -300,7 +326,8 @@
      */
     private function getClassImports(ReflectionClass $class)
     {
-        if (isset($this->imports[$name = $class->getName()])) {
+        $name = $class->getName();
+        if (isset($this->imports[$name])) {
             return $this->imports[$name];
         }