Security update for Core, with self-updated composer
[yaffs-website] / vendor / doctrine / annotations / lib / Doctrine / Common / Annotations / AnnotationReader.php
index 4ebd1fb4a00c50d2493f89733b3a1590fabc1e11..6c579775fd682fb344db60a6f17a7d1ce5c25c24 100644 (file)
@@ -102,6 +102,15 @@ class AnnotationReader implements Reader
         'startuml' => true, 'enduml' => true,
     );
 
+    /**
+     * 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.
      *
@@ -112,6 +121,16 @@ class AnnotationReader implements Reader
         self::$globalIgnoredNames[$name] = true;
     }
 
+    /**
+     * 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.
      *
@@ -151,8 +170,10 @@ class AnnotationReader implements Reader
      * 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 @@ class AnnotationReader implements Reader
 
         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 @@ class AnnotationReader implements Reader
         $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 @@ class AnnotationReader implements Reader
         $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 @@ class AnnotationReader implements Reader
         $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 @@ class AnnotationReader implements Reader
      */
     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 @@ class AnnotationReader implements Reader
      */
     private function getClassImports(ReflectionClass $class)
     {
-        if (isset($this->imports[$name = $class->getName()])) {
+        $name = $class->getName();
+        if (isset($this->imports[$name])) {
             return $this->imports[$name];
         }