diff --git a/docs/en/index.rst b/docs/en/index.rst index 7a6be485b..59053125b 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -77,14 +77,11 @@ annotations of a class. A common one is echo $myAnnotation->myProperty; // result: "value" -A reader has multiple methods to access the annotations of a class. - Note that ``AnnotationRegistry::registerLoader('class_exists')`` only works if you already have an autoloader configured (i.e. composer autoloader). Otherwise, :ref:`please take a look to the other annotation autoload mechanisms `. -A reader has multiple methods to access the annotations -of a class. +A reader has multiple methods to access the annotations of a class. :ref:`Read more about handling annotations. ` diff --git a/lib/Doctrine/Common/Annotations/AnnotationReader.php b/lib/Doctrine/Common/Annotations/AnnotationReader.php index 107d1bb77..8811c2951 100644 --- a/lib/Doctrine/Common/Annotations/AnnotationReader.php +++ b/lib/Doctrine/Common/Annotations/AnnotationReader.php @@ -194,7 +194,8 @@ public function __construct(DocParser $parser = null) throw AnnotationException::optimizerPlusSaveComments(); } - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php'); + // Make sure that the IgnoreAnnotation annotation is loaded + class_exists(IgnoreAnnotation::class); $this->parser = $parser ?: new DocParser(); diff --git a/lib/Doctrine/Common/Annotations/DocParser.php b/lib/Doctrine/Common/Annotations/DocParser.php index e1f5de315..741149ae2 100644 --- a/lib/Doctrine/Common/Annotations/DocParser.php +++ b/lib/Doctrine/Common/Annotations/DocParser.php @@ -490,10 +490,11 @@ private function collectAnnotationMetadata($name) 'attributes' => 'Doctrine\Common\Annotations\Annotation\Attributes' ]); - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Enum.php'); - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Target.php'); - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attribute.php'); - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attributes.php'); + // Make sure that annotations from metadata are loaded + class_exists(Enum::class); + class_exists(Target::class); + class_exists(Attribute::class); + class_exists(Attributes::class); } $class = new \ReflectionClass($name);