mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-30 22:53:31 +00:00
[Reflection] Clean up getAncestors() call, use merge parents and interfaces (#1536)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
45e7eea690
commit
a16f614af3
|
@ -82,18 +82,13 @@ final class FamilyRelationsAnalyzer
|
|||
throw new ShouldNotHappenException();
|
||||
}
|
||||
|
||||
$ancestorClassReflections = $classReflection->getAncestors();
|
||||
$ancestorClassReflections = array_merge($classReflection->getParents(), $classReflection->getInterfaces());
|
||||
|
||||
$propertyName = $this->nodeNameResolver->getName($property);
|
||||
$kindPropertyFetch = $this->getKindPropertyFetch($property);
|
||||
|
||||
$className = $classReflection->getName();
|
||||
|
||||
foreach ($ancestorClassReflections as $ancestorClassReflection) {
|
||||
$ancestorClassName = $ancestorClassReflection->getName();
|
||||
if ($ancestorClassName === $className) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($ancestorClassReflection->isSubclassOf('PHPUnit\Framework\TestCase')) {
|
||||
continue;
|
||||
|
|
|
@ -115,12 +115,8 @@ final class ClassMethodParamVendorLockResolver
|
|||
string $methodName,
|
||||
string $filePathPartName
|
||||
): bool {
|
||||
foreach ($classReflection->getAncestors() as $ancestorClassReflection) {
|
||||
// skip self
|
||||
if ($ancestorClassReflection === $classReflection) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ancestorClassReflections = array_merge($classReflection->getParents(), $classReflection->getInterfaces());
|
||||
foreach ($ancestorClassReflections as $ancestorClassReflection) {
|
||||
// parent type
|
||||
if (! $ancestorClassReflection->hasNativeMethod($methodName)) {
|
||||
continue;
|
||||
|
|
|
@ -45,14 +45,12 @@ final class PhpAttributeAnalyzer
|
|||
}
|
||||
|
||||
$classReflection = $this->reflectionProvider->getClass($className);
|
||||
$ancestorClassReflections = $classReflection->getAncestors();
|
||||
$ancestorClassReflections = array_merge($classReflection->getParents(), $classReflection->getInterfaces());
|
||||
|
||||
foreach ($ancestorClassReflections as $ancestorClassReflection) {
|
||||
$ancestorClassName = $ancestorClassReflection->getName();
|
||||
if ($ancestorClassName === $className) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = $this->astResolver->resolveClassFromName($ancestorClassName);
|
||||
|
||||
if (! $class instanceof Class_) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -31,11 +31,8 @@ final class ClassManipulator
|
|||
}
|
||||
|
||||
$classReflection = $this->reflectionProvider->getClass($objectType->getClassName());
|
||||
foreach ($classReflection->getAncestors() as $ancestorClassReflection) {
|
||||
if ($classReflection === $ancestorClassReflection) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ancestorClassReflections = array_merge($classReflection->getParents(), $classReflection->getInterfaces());
|
||||
foreach ($ancestorClassReflections as $ancestorClassReflection) {
|
||||
if (! $ancestorClassReflection->hasMethod($oldMethod)) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user