Skip to content

Commit 7a94297

Browse files
committed
fixup! fixup! avoid type casting against stmts aware interface, as no node has it
1 parent ba21150 commit 7a94297

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
use Rector\NodeManipulator\StmtsManipulator;
2626
use Rector\Php\ReservedKeywordAnalyzer;
2727
use Rector\PhpParser\Node\BetterNodeFinder;
28+
use Rector\PhpParser\NodeGroups;
2829
use Rector\Rector\AbstractRector;
2930
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
3031
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
32+
use Webmozart\Assert\Assert;
3133

3234
/**
3335
* @see \Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\RemoveUnusedVariableAssignRectorTest
@@ -164,10 +166,12 @@ private function shouldSkip(array $stmts): bool
164166
*/
165167
private function collectAssignRefVariableNames(Stmt $stmt, array &$refVariableNames): void
166168
{
167-
if (! $stmt instanceof StmtsAwareInterface) {
169+
if (! NodeGroups::matchesStmtsAware($stmt)) {
168170
return;
169171
}
170172

173+
Assert::propertyExists($stmt, 'stmts');
174+
171175
$this->traverseNodesWithCallable(
172176
$stmt,
173177
function (Node $subNode) use (&$refVariableNames): Node {

0 commit comments

Comments
 (0)