|
4 | 4 |
|
5 | 5 | namespace Rector\PHPUnit\PHPUnit120\Rector\CallLike; |
6 | 6 |
|
| 7 | +use PhpParser\Node\Expr\PropertyFetch; |
7 | 8 | use PhpParser\Node; |
8 | 9 | use PhpParser\Node\ArrayItem; |
9 | 10 | use PhpParser\Node\Expr; |
|
14 | 15 | use PhpParser\Node\Identifier; |
15 | 16 | use PhpParser\Node\Stmt\ClassMethod; |
16 | 17 | use PhpParser\Node\Stmt\Expression; |
17 | | -use Rector\PHPStan\ScopeFetcher; |
18 | 18 | use Rector\PHPUnit\CodeQuality\NodeAnalyser\MockObjectExprDetector; |
19 | | -use Rector\PHPUnit\Enum\PHPUnitClassName; |
20 | 19 | use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; |
21 | 20 | use Rector\Rector\AbstractRector; |
22 | 21 | use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; |
@@ -90,13 +89,7 @@ public function getNodeTypes(): array |
90 | 89 | */ |
91 | 90 | public function refactor(Node $node): MethodCall|StaticCall|New_|ArrayItem|ClassMethod|null |
92 | 91 | { |
93 | | - $scope = ScopeFetcher::fetch($node); |
94 | | - if (! $scope->isInClass()) { |
95 | | - return null; |
96 | | - } |
97 | | - |
98 | | - $classReflection = $scope->getClassReflection(); |
99 | | - if (! $classReflection->is(PHPUnitClassName::TEST_CASE)) { |
| 92 | + if (! $this->testsNodeAnalyzer->isInTestClass($node)) { |
100 | 93 | return null; |
101 | 94 | } |
102 | 95 |
|
@@ -165,6 +158,12 @@ private function refactorClassMethod(ClassMethod $classMethod): ?ClassMethod |
165 | 158 | } |
166 | 159 |
|
167 | 160 | $assign = $stmt->expr; |
| 161 | + |
| 162 | + // handled in another rule |
| 163 | + if ($assign->var instanceof PropertyFetch) { |
| 164 | + continue; |
| 165 | + } |
| 166 | + |
168 | 167 | $createMockMethodCall = $this->matchCreateMockMethodCall($assign->expr); |
169 | 168 |
|
170 | 169 | if (! $createMockMethodCall instanceof MethodCall) { |
|
0 commit comments