diff --git a/packages/VendorLocker/NodeVendorLocker/ClassMethodParamVendorLockResolver.php b/packages/VendorLocker/NodeVendorLocker/ClassMethodParamVendorLockResolver.php index be62c305d52c..5dfd3b92096e 100644 --- a/packages/VendorLocker/NodeVendorLocker/ClassMethodParamVendorLockResolver.php +++ b/packages/VendorLocker/NodeVendorLocker/ClassMethodParamVendorLockResolver.php @@ -59,11 +59,22 @@ public function isVendorLocked(ClassMethod $classMethod, int $paramPosition): bo return false; } - if (! $this->classReflectionAncestorAnalyzer->hasAncestors($classReflection)) { - return false; + $methodName = $this->nodeNameResolver->getName($classMethod); + foreach ($classReflection->getAncestors() as $ancestorClassReflection) { + // skip self + if ($ancestorClassReflection === $classReflection) { + continue; + } + + if (! $classReflection->hasNativeMethod($methodName)) { + continue; + } } - $methodName = $this->nodeNameResolver->getName($classMethod); +// if (! $this->classReflectionAncestorAnalyzer->hasAncestors($classReflection)) { +// return false; +// } + if ($classReflection->getParentClass() !== false) { $vendorLock = $this->isParentClassVendorLocking( diff --git a/packages/VendorLocker/Reflection/ClassReflectionAncestorAnalyzer.php b/packages/VendorLocker/Reflection/ClassReflectionAncestorAnalyzer.php index 9abaf1839f16..50440b7db471 100644 --- a/packages/VendorLocker/Reflection/ClassReflectionAncestorAnalyzer.php +++ b/packages/VendorLocker/Reflection/ClassReflectionAncestorAnalyzer.php @@ -5,41 +5,11 @@ namespace Rector\VendorLocker\Reflection; use PHPStan\Reflection\ClassReflection; -use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer; final class ClassReflectionAncestorAnalyzer { - /** - * @var FamilyRelationsAnalyzer - */ - private $familyRelationsAnalyzer; - - public function __construct(FamilyRelationsAnalyzer $familyRelationsAnalyzer) - { - $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; - } - public function hasAncestors(ClassReflection $classReflection): bool { - if ($classReflection->isClass()) { - // has at least interface - if ($classReflection->getInterfaces() !== []) { - return true; - } - - // has at least one parent class - if ($classReflection->getParents() !== []) { - return true; - } - - $childrenClassReflections = $this->familyRelationsAnalyzer->getChildrenOfClassReflection($classReflection); - return $childrenClassReflections !== []; - } - - if ($classReflection->isInterface()) { - return $classReflection->getInterfaces() !== []; - } - - return false; + return $classReflection->getAncestors() !== [$classReflection]; } } diff --git a/rules/CodeQuality/NodeAnalyzer/ForeachAnalyzer.php b/rules/CodeQuality/NodeAnalyzer/ForeachAnalyzer.php index 18414919957b..0e9eeaee8e04 100644 --- a/rules/CodeQuality/NodeAnalyzer/ForeachAnalyzer.php +++ b/rules/CodeQuality/NodeAnalyzer/ForeachAnalyzer.php @@ -112,10 +112,6 @@ function (Node $node) use ($foreachedValue, $singleValue, $keyValueName): ?Expr } // is dim same as key value name, ...[$i] -// if ($node->dim === null) { -// return null; -// } -// if (! $node->dim instanceof Variable) { return null; }