diff --git a/lib/Doctrine/Common/Annotations/AnnotationReader.php b/lib/Doctrine/Common/Annotations/AnnotationReader.php index 7d63323ca..cf3a6254f 100644 --- a/lib/Doctrine/Common/Annotations/AnnotationReader.php +++ b/lib/Doctrine/Common/Annotations/AnnotationReader.php @@ -197,6 +197,7 @@ public function __construct(DocParser $parser = null) $this->preParser->setImports(self::$globalImports); $this->preParser->setIgnoreNotImportedAnnotations(true); + $this->preParser->setIgnoredAnnotationNames(self::$globalIgnoredNames); $this->phpParser = new PhpParser; } diff --git a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php index da94429a1..15fbab422 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php @@ -138,4 +138,22 @@ public function testPhpCsSuppressAnnotationIsIgnored() self::assertEmpty($reader->getMethodAnnotations($ref->getMethod('foo'))); } + + public function testGloballyIgnoredAnnotationNotIgnored() : void + { + $reader = $this->getReader(); + $class = new \ReflectionClass(Fixtures\ClassDDC1660::class); + $testLoader = static function (string $className) : bool { + if ($className === 'since') { + throw new \InvalidArgumentException('Globally ignored annotation names should never be passed to an autoloader.'); + } + return false; + }; + spl_autoload_register($testLoader, true, true); + try { + self::assertEmpty($reader->getClassAnnotations($class)); + } finally { + spl_autoload_unregister($testLoader); + } + } }