Skip to content

Commit 4788be7

Browse files
authored
Merge pull request #12 from hostep/fix-magic-methods-called-directly-on-dataobject
Fix magic methods called directly on dataobject
2 parents 75381f5 + 3e63f79 commit 4788be7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace bitExpert\PHPStan\Magento\Reflection\Framework;
1414

1515
use bitExpert\PHPStan\Magento\Reflection\AbstractMagicMethodReflectionExtension;
16+
use Magento\Framework\DataObject;
1617
use PHPStan\Reflection\ClassReflection;
1718

1819
class DataObjectMagicMethodReflectionExtension extends AbstractMagicMethodReflectionExtension
@@ -24,7 +25,10 @@ class DataObjectMagicMethodReflectionExtension extends AbstractMagicMethodReflec
2425
*/
2526
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
2627
{
27-
return $classReflection->isSubclassOf('Magento\Framework\DataObject') &&
28+
$isDataObject = $classReflection->getName() === DataObject::class ||
29+
$classReflection->isSubclassOf(DataObject::class);
30+
31+
return $isDataObject &&
2832
in_array(substr($methodName, 0, 3), ['get', 'set', 'uns', 'has']);
2933
}
3034
}

0 commit comments

Comments
 (0)