diff --git a/lib/Doctrine/Annotations/AnnotationReader.php b/lib/Doctrine/Annotations/AnnotationReader.php index 1f2a2db68..51397dd3a 100644 --- a/lib/Doctrine/Annotations/AnnotationReader.php +++ b/lib/Doctrine/Annotations/AnnotationReader.php @@ -181,6 +181,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/Annotations/AbstractReaderTest.php b/tests/Doctrine/Tests/Annotations/AbstractReaderTest.php index a52fe21e9..b218db081 100644 --- a/tests/Doctrine/Tests/Annotations/AbstractReaderTest.php +++ b/tests/Doctrine/Tests/Annotations/AbstractReaderTest.php @@ -408,6 +408,28 @@ public function testInvalidAnnotationButIgnored() self::assertEmpty($reader->getPropertyAnnotations($class->getProperty('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); + } + } + public function testAnnotationEnumeratorException() { $reader = $this->getReader();