Skip to content

Commit

Permalink
Use createFromNode() from PhpDocInfoFactory on RemoveUnusedPrivateMet…
Browse files Browse the repository at this point in the history
…hodRector
  • Loading branch information
samsonasik committed Nov 25, 2024
1 parent 1d7208b commit 3e32637
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\Reflection\ClassReflection;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\DeadCode\NodeAnalyzer\IsClassMethodUsedAnalyzer;
use Rector\NodeTypeResolver\Node\AttributeKey;
Expand Down Expand Up @@ -147,13 +148,14 @@ private function collectTestMethodsUsesPrivateDataProvider(ClassReflection $clas
continue;
}

$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
if ($phpDocInfo->hasByName('dataProvider')) {
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($classMethod);
if ($phpDocInfo instanceof PhpDocInfo && $phpDocInfo->hasByName('dataProvider')) {
$dataProvider = $phpDocInfo->getByName('dataProvider');
if ($dataProvider instanceof PhpDocTagNode && $dataProvider->value instanceof GenericTagValueNode) {
$dataProviderMethod = $class->getMethod($dataProvider->value->value);
if ($dataProviderMethod instanceof ClassMethod && $dataProviderMethod->isPrivate()) {
$privateMethods[] = $dataProvider->value->value;
continue;
}
}
}
Expand Down

0 comments on commit 3e32637

Please sign in to comment.