From 8ed9053253c87327e62cb8baae05658255918531 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 9 Apr 2020 13:40:00 +0200 Subject: [PATCH] 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);