Skip to content

Commit

Permalink
[stabilize] Remove family tree check from ClassMethodParamVendorLockR…
Browse files Browse the repository at this point in the history
…esolver as not reliable (#5536)
  • Loading branch information
TomasVotruba authored Jan 31, 2024
1 parent cbc0773 commit 8b7c8c7
Showing 1 changed file with 0 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\Reflection\ClassReflection;
use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer;
use Rector\FileSystem\FilePathHelper;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\Reflection\ReflectionResolver;
Expand All @@ -15,7 +14,6 @@
{
public function __construct(
private NodeNameResolver $nodeNameResolver,
private FamilyRelationsAnalyzer $familyRelationsAnalyzer,
private ReflectionResolver $reflectionResolver,
private FilePathHelper $filePathHelper
) {
Expand All @@ -34,9 +32,6 @@ public function isVendorLocked(ClassMethod $classMethod): bool

/** @var string $methodName */
$methodName = $this->nodeNameResolver->getName($classMethod);
if ($this->hasTraitMethodVendorLock($classReflection, $methodName)) {
return true;
}

// has interface vendor lock? → better skip it, as PHPStan has access only to just analyzed classes
if ($this->hasParentInterfaceMethod($classReflection, $methodName)) {
Expand All @@ -46,22 +41,6 @@ public function isVendorLocked(ClassMethod $classMethod): bool
return $this->hasClassMethodLockMatchingFileName($classReflection, $methodName, '/vendor/');
}

private function hasTraitMethodVendorLock(ClassReflection $classReflection, string $methodName): bool
{
$relatedReflectionClasses = $this->familyRelationsAnalyzer->getChildrenOfClassReflection($classReflection);

foreach ($relatedReflectionClasses as $relatedReflectionClass) {
foreach ($relatedReflectionClass->getTraits() as $traitReflectionClass) {
/** @var ClassReflection $traitReflectionClass */
if ($traitReflectionClass->hasMethod($methodName)) {
return true;
}
}
}

return false;
}

/**
* Has interface even in our project?
* Better skip it, as PHPStan has access only to just analyzed classes.
Expand Down

0 comments on commit 8b7c8c7

Please sign in to comment.