Skip to content

Commit 05db8be

Browse files
stofondrejmirtes
authored andcommitted
Fix the support for Gedmo attributes
Attributes should be supported even without an annotation reader, as they are usable without doctrine/annotations
1 parent f728e0d commit 05db8be

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Rules/Gedmo/PropertiesExtension.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,27 @@ public function isInitialized(PropertyReflection $property, string $propertyName
7272
*/
7373
private function isGedmoAnnotationOrAttribute(PropertyReflection $property, string $propertyName, array $classList): bool
7474
{
75-
if ($this->annotationReader === null) {
76-
return false;
77-
}
78-
7975
$classReflection = $property->getDeclaringClass();
8076
if ($this->objectMetadataResolver->isTransient($classReflection->getName())) {
8177
return false;
8278
}
8379

8480
$propertyReflection = $classReflection->getNativeReflection()->getProperty($propertyName);
8581

86-
$annotations = $this->annotationReader->getPropertyAnnotations($propertyReflection);
87-
foreach ($annotations as $annotation) {
88-
if (in_array(get_class($annotation), $classList, true)) {
82+
$attributes = $propertyReflection->getAttributes();
83+
foreach ($attributes as $attribute) {
84+
if (in_array($attribute->getName(), $classList, true)) {
8985
return true;
9086
}
9187
}
9288

93-
$attributes = $propertyReflection->getAttributes();
94-
foreach ($attributes as $attribute) {
95-
if (in_array($attribute->getName(), $classList, true)) {
89+
if ($this->annotationReader === null) {
90+
return false;
91+
}
92+
93+
$annotations = $this->annotationReader->getPropertyAnnotations($propertyReflection);
94+
foreach ($annotations as $annotation) {
95+
if (in_array(get_class($annotation), $classList, true)) {
9696
return true;
9797
}
9898
}

0 commit comments

Comments
 (0)