diff --git a/src/Rules/Gedmo/PropertiesExtension.php b/src/Rules/Gedmo/PropertiesExtension.php index c0a9239f..d43b4308 100644 --- a/src/Rules/Gedmo/PropertiesExtension.php +++ b/src/Rules/Gedmo/PropertiesExtension.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Gedmo; +use Doctrine\Common\Annotations\AnnotationException; use Doctrine\Common\Annotations\AnnotationReader; use Gedmo\Mapping\Annotation as Gedmo; use PHPStan\Reflection\PropertyReflection; @@ -90,7 +91,13 @@ private function isGedmoAnnotationOrAttribute(PropertyReflection $property, stri return false; } - $annotations = $this->annotationReader->getPropertyAnnotations($propertyReflection); + try { + $annotations = $this->annotationReader->getPropertyAnnotations($propertyReflection); + } catch (AnnotationException $e) { + // Suppress the "The annotation X was never imported." exception in case the `objectManagerLoader` is not configured + return false; + } + foreach ($annotations as $annotation) { if (in_array(get_class($annotation), $classList, true)) { return true;