Skip to content

Commit 0a8fa83

Browse files
authored
Handle AnnotationException in Gedmo\PropertiesExtension
1 parent cba50e9 commit 0a8fa83

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Rules/Gedmo/PropertiesExtension.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHPStan\Rules\Gedmo;
44

5+
use Doctrine\Common\Annotations\AnnotationException;
56
use Doctrine\Common\Annotations\AnnotationReader;
67
use Gedmo\Mapping\Annotation as Gedmo;
78
use PHPStan\Reflection\PropertyReflection;
@@ -90,7 +91,13 @@ private function isGedmoAnnotationOrAttribute(PropertyReflection $property, stri
9091
return false;
9192
}
9293

93-
$annotations = $this->annotationReader->getPropertyAnnotations($propertyReflection);
94+
try {
95+
$annotations = $this->annotationReader->getPropertyAnnotations($propertyReflection);
96+
} catch (AnnotationException $e) {
97+
// Suppress the "The annotation X was never imported." exception in case the `objectManagerLoader` is not configured
98+
return false;
99+
}
100+
94101
foreach ($annotations as $annotation) {
95102
if (in_array(get_class($annotation), $classList, true)) {
96103
return true;

0 commit comments

Comments
 (0)