Skip to content

Commit b136cb8

Browse files
authored
[perf] Skip non-test class early in AddProphecyTraitRector (#793)
1 parent 4acf210 commit b136cb8

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\PHPUnit100\Rector\Class_\AddProphecyTraitRector\Fixture;
4+
5+
final class SomeService
6+
{
7+
public function run(): void
8+
{
9+
$prophecy = $this->prophesize(\AnInterface::class);
10+
}
11+
}

‎rules/PHPUnit100/Rector/Class_/AddProphecyTraitRector.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public function refactor(Node $node): ?Node
106106

107107
private function shouldSkipClass(Class_ $class): bool
108108
{
109+
if (! $this->testsNodeAnalyzer->isInTestClass($class)) {
110+
return true;
111+
}
112+
109113
$hasProphesizeMethodCall = (bool) $this->betterNodeFinder->findFirst(
110114
$class,
111115
fn (Node $node): bool => $this->testsNodeAnalyzer->isAssertMethodCallName($node, 'prophesize')

0 commit comments

Comments
 (0)