Skip to content

Commit a72458c

Browse files
committed
Optimize detection of DataObject parent class
Apparently $classReflection->isSubclassOf() does not take the whole inheritance chain into account, it will just check if the direct parent class is DataObject.
1 parent fed0bf8 commit a72458c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/bitExpert/PHPStan/Magento/Reflection/Framework/DataObjectMagicMethodReflectionExtension.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ class DataObjectMagicMethodReflectionExtension extends AbstractMagicMethodReflec
2525
*/
2626
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
2727
{
28-
$isDataObject = $classReflection->getName() === DataObject::class ||
29-
$classReflection->isSubclassOf(DataObject::class);
30-
31-
return $isDataObject &&
28+
$parentClasses = $classReflection->getParentClassesNames();
29+
return in_array(DataObject::class, $parentClasses, true) &&
3230
in_array(substr($methodName, 0, 3), ['get', 'set', 'uns', 'has']);
3331
}
3432
}

0 commit comments

Comments
 (0)