Skip to content

Commit f9c08fa

Browse files
authored
[PHPUnit 12] Skip First class callable on DirectInstanceOverMockArgRector (#610)
* [PHPUnit 12] Skip First class callable on DirectInstanceOverMockArgRector * fix
1 parent 6bc82f2 commit f9c08fa

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
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\CallLike\DirectInstanceOverMockArgRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class SkipFirstClassCallable extends TestCase
8+
{
9+
public function testThat()
10+
{
11+
AnyClass::staticRun(...);
12+
}
13+
}

rules/CodeQuality/Rector/CallLike/DirectInstanceOverMockArgRector.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,13 @@ public function refactor(Node $node): MethodCall|StaticCall|New_|ArrayItem|null
101101
$hasChanged = false;
102102

103103
if ($node instanceof ArrayItem) {
104-
105104
return $this->refactorArrayItem($node);
106105
}
107106

107+
if ($node->isFirstClassCallable()) {
108+
return null;
109+
}
110+
108111
foreach ($node->getArgs() as $arg) {
109112
$firstArg = $this->matchCreateMockMethodCallArg($arg->value);
110113
if (! $firstArg instanceof Arg) {

0 commit comments

Comments
 (0)