Skip to content

Commit f6a25b2

Browse files
authored
[DeadCode] Remove whole assign statement on unused createStub() in tests (#8257)
1 parent 03ef6cf commit f6a25b2

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class CreateStubInTest extends TestCase
8+
{
9+
public function test($params)
10+
{
11+
$user = $this->createStub('SomeClass');
12+
}
13+
}
14+
15+
?>
16+
-----
17+
<?php
18+
19+
namespace Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Fixture;
20+
21+
use PHPUnit\Framework\TestCase;
22+
23+
final class CreateStubInTest extends TestCase
24+
{
25+
public function test($params)
26+
{
27+
}
28+
}
29+
30+
?>

‎rules/DeadCode/SideEffect/SideEffectNodeDetector.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private function isTestMock(MethodCall|StaticCall $node): bool
9696
return false;
9797
}
9898

99-
return $this->nodeNameResolver->isName($node->name, 'createMock');
99+
return $this->nodeNameResolver->isNames($node->name, ['createMock', 'createStub']);
100100
}
101101

102102
private function isPhpParser(New_ $new): bool

0 commit comments

Comments
 (0)