File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
rules-tests/CodeQuality/Rector/Expression/DecorateWillReturnMapWithExpectsMockRector/Fixture
rules/CodeQuality/Rector/Expression Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \PHPUnit \Tests \CodeQuality \Rector \Expression \DecorateWillReturnMapWithExpectsMockRector \Fixture ;
6+
7+ final class SkipFromSetup extends \PHPUnit \Framework \TestCase
8+ {
9+ protected function setUp (): void
10+ {
11+ $ someMock = $ this ->createMock (\stdClass::class);
12+ $ someMock ->method ('some ' )->willReturnMap ([1 , 2 ]);
13+ }
14+ }
Original file line number Diff line number Diff line change 1212use PhpParser \Node \Identifier ;
1313use PhpParser \Node \Scalar \Int_ ;
1414use PhpParser \Node \Stmt \Expression ;
15+ use Rector \PHPStan \ScopeFetcher ;
1516use Rector \Rector \AbstractRector ;
17+ use Rector \ValueObject \MethodName ;
1618use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
1719use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
1820
@@ -92,6 +94,13 @@ public function refactor(Node $node)
9294 return null ;
9395 }
9496
97+ $ scope = ScopeFetcher::fetch ($ node );
98+
99+ // allowed as can be flexible
100+ if ($ scope ->getFunctionName () === MethodName::SET_UP ) {
101+ return null ;
102+ }
103+
95104 $ topmostCall = $ this ->resolveTopmostCall ($ methodCall );
96105
97106 // already covered
You can’t perform that action at this time.
0 commit comments