Skip to content

Commit

Permalink
Handle AnnotationException in Gedmo\PropertiesExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
luxemate authored Oct 29, 2023
1 parent cba50e9 commit 0a8fa83
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Rules/Gedmo/PropertiesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0a8fa83

Please sign in to comment.