diff --git a/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php b/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php index fe649f05ec0..43288c41759 100644 --- a/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php +++ b/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php @@ -37,14 +37,20 @@ public function getParentClassMethod(ClassMethod $classMethod): ?MethodReflectio /** @var string $methodName */ $methodName = $this->nodeNameResolver->getName($classMethod); - $parentClassReflections = array_merge($classReflection->getParents(), $classReflection->getInterfaces()); + $parentClassReflection = $classReflection->getParentClass(); + while ($parentClassReflection instanceof ClassReflection) { + if ($parentClassReflection->hasNativeMethod($methodName)) { + return $parentClassReflection->getNativeMethod($methodName); + } + $parentClassReflection = $parentClassReflection->getParentClass(); + } - foreach ($parentClassReflections as $parentClassReflection) { - if (! $parentClassReflection->hasNativeMethod($methodName)) { + foreach ($classReflection->getInterfaces() as $interfaceReflection) { + if (! $interfaceReflection->hasNativeMethod($methodName)) { continue; } - return $parentClassReflection->getNativeMethod($methodName); + return $interfaceReflection->getNativeMethod($methodName); } return null;