Skip to content

Commit 8fd63f1

Browse files
authored
[CodeQuality] Skip first class callable and argument less on MatchAssertSameExpectedTypeRector (#511)
1 parent 4122b94 commit 8fd63f1

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class SkipArgumentLess extends TestCase
8+
{
9+
public function test()
10+
{
11+
$this->assertSame(1);
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class SkipFirstClassCallable extends TestCase
8+
{
9+
public function test()
10+
{
11+
$this->assertSame(...);
12+
}
13+
}

rules/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ public function refactor(Node $node): ?Node
8686
return null;
8787
}
8888

89+
if ($node->isFirstClassCallable()) {
90+
return null;
91+
}
92+
93+
if (count($node->getArgs()) < 2) {
94+
return null;
95+
}
96+
8997
$expectedArg = $node->getArgs()[0];
9098
if (! $expectedArg->value instanceof String_ && ! $expectedArg->value instanceof LNumber) {
9199
return null;

0 commit comments

Comments
 (0)