|
14 | 14 | use PHPStan\Reflection\ReflectionProvider; |
15 | 15 | use Rector\Doctrine\NodeAnalyzer\AttributeFinder; |
16 | 16 | use Rector\PhpParser\Node\BetterNodeFinder; |
17 | | -use Rector\PhpParser\NodeFinder\PropertyFetchFinder; |
18 | 17 | use Rector\PHPUnit\Enum\PHPUnitAttribute; |
19 | 18 | use Rector\PHPUnit\Enum\PHPUnitClassName; |
20 | 19 | use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; |
@@ -97,7 +96,7 @@ public function refactor(Node $node): ?Class_ |
97 | 96 | public function getRuleDefinition(): RuleDefinition |
98 | 97 | { |
99 | 98 | return new RuleDefinition( |
100 | | - 'Add #[AllowMockObjectsWithoutExpectations] attribute to PHPUnit test classes with mock properties used in multiple methods', |
| 99 | + 'Add #[AllowMockObjectsWithoutExpectations] attribute to PHPUnit test classes with mock properties used in multiple methods but one, to avoid irrelevant notices in tests run', |
101 | 100 | [ |
102 | 101 | new CodeSample( |
103 | 102 | <<<'CODE_SAMPLE' |
@@ -202,12 +201,14 @@ private function shouldSkipClass(Class_ $class): bool |
202 | 201 | return ! $setupClassMethod instanceof ClassMethod; |
203 | 202 | } |
204 | 203 |
|
205 | | - private function isClassMethodUsingMethodCallOnPropertyNamed(ClassMethod $classMethod, string $mockObjectPropertyName): bool |
206 | | - { |
| 204 | + private function isClassMethodUsingMethodCallOnPropertyNamed( |
| 205 | + ClassMethod $classMethod, |
| 206 | + string $mockObjectPropertyName |
| 207 | + ): bool { |
207 | 208 | /** @var Node\Expr\MethodCall[] $methodCalls */ |
208 | 209 | $methodCalls = $this->betterNodeFinder->findInstancesOfScoped([$classMethod], [Node\Expr\MethodCall::class]); |
209 | 210 | foreach ($methodCalls as $methodCall) { |
210 | | - if (!$methodCall->var instanceof Node\Expr\PropertyFetch) { |
| 211 | + if (! $methodCall->var instanceof Node\Expr\PropertyFetch) { |
211 | 212 | continue; |
212 | 213 | } |
213 | 214 |
|
|
0 commit comments