File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
rules-tests/CodeQuality/Rector/MethodCall/WithCallbackIdenticalToStandaloneAssertsRector/Fixture
rules/CodeQuality/Rector/MethodCall Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \PHPUnit \Tests \CodeQuality \Rector \MethodCall \WithCallbackIdenticalToStandaloneAssertsRector \Fixture ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+
7+ final class SkipThis extends TestCase
8+ {
9+ private $ expectedValue ;
10+
11+ public function test ()
12+ {
13+ $ expectedValue = 100 ;
14+ $ someMock = $ this ->getMockBuilder ('AnyType ' )->getMock ();
15+
16+ $ someMock ->expects ($ this ->any ())
17+ ->method ('trans ' )
18+ ->with (
19+ $ this ->callback (fn ($ args ): bool => count ($ args ) === 5 && $ args [0 ] === $ this ->expectedValue )
20+ );
21+ }
22+ }
23+
24+ ?>
25+ -----
26+ <?php
27+
28+ namespace Rector \PHPUnit \Tests \CodeQuality \Rector \MethodCall \WithCallbackIdenticalToStandaloneAssertsRector \Fixture ;
29+
30+ use PHPUnit \Framework \TestCase ;
31+
32+ final class SkipThis extends TestCase
33+ {
34+ private $ expectedValue ;
35+
36+ public function test ()
37+ {
38+ $ expectedValue = 100 ;
39+ $ someMock = $ this ->getMockBuilder ('AnyType ' )->getMock ();
40+
41+ $ someMock ->expects ($ this ->any ())
42+ ->method ('trans ' )
43+ ->with (
44+ $ this ->callback (function ($ args ): void {
45+ $ this ->assertCount (5 , $ args );
46+ $ this ->assertSame ($ this ->expectedValue , $ args [0 ]);
47+ })
48+ );
49+ }
50+ }
51+
52+ ?>
Original file line number Diff line number Diff line change @@ -251,6 +251,7 @@ private function resolveExternalClosureUses(ArrowFunction $arrowFunction): array
251251 }
252252
253253 $ externalVariableNames = array_unique ($ externalVariableNames );
254+ $ externalVariableNames = array_diff ($ externalVariableNames , ['this ' ]);
254255
255256 $ closureUses = [];
256257 foreach ($ externalVariableNames as $ externalVariableName ) {
You can’t perform that action at this time.
0 commit comments