From c3ac7762249f0486329f1c6fa530d83c0f964f61 Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Thu, 2 Apr 2020 22:00:35 +0200 Subject: [PATCH 1/2] Fix duplicate text in documentation --- docs/en/index.rst | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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. ` From 8ed9053253c87327e62cb8baae05658255918531 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 9 Apr 2020 13:40:00 +0200 Subject: [PATCH 2/2] Fix broken autoloading due to Reader calling registerFile --- lib/Doctrine/Common/Annotations/AnnotationReader.php | 3 ++- lib/Doctrine/Common/Annotations/DocParser.php | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) 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);