|
11 | 11 | * Run on both branches to compare. CPU (user+sys) is the reliable metric; wall is noisy. |
12 | 12 | */ |
13 | 13 |
|
14 | | -use PhpParser\Node\Stmt\ClassMethod; |
| 14 | +use PhpParser\Node\Stmt\Class_; |
15 | 15 | use Rector\DependencyInjection\LazyContainerFactory; |
16 | 16 | use Rector\PhpParser\Node\BetterNodeFinder; |
17 | 17 | use Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector; |
|
93 | 93 | $rector = $rectorConfig->make(AddDoesNotPerformAssertionToNonAssertingTestRector::class); |
94 | 94 |
|
95 | 95 | // parse test files up front, parent files are left for the rule to resolve |
96 | | -$classMethods = []; |
| 96 | +$classes = []; |
97 | 97 | foreach ($testFilePaths as $testFilePath) { |
98 | 98 | $stmts = $testingParser->parseFileToDecoratedNodes($testFilePath); |
99 | | - $classMethods = [...$classMethods, ...$betterNodeFinder->findInstanceOf($stmts, ClassMethod::class)]; |
| 99 | + $classes = [...$classes, ...$betterNodeFinder->findInstanceOf($stmts, Class_::class)]; |
100 | 100 | } |
101 | 101 |
|
102 | 102 | $cpuSeconds = static function (): float { |
|
109 | 109 | $cpuStart = $cpuSeconds(); |
110 | 110 |
|
111 | 111 | $changedCount = 0; |
112 | | -foreach ($classMethods as $classMethod) { |
113 | | - if ($rector->refactor($classMethod) instanceof ClassMethod) { |
| 112 | +foreach ($classes as $class) { |
| 113 | + if ($rector->refactor($class) instanceof Class_) { |
114 | 114 | ++$changedCount; |
115 | 115 | } |
116 | 116 | } |
|
121 | 121 | array_map('unlink', glob($directory . '/*.php')); |
122 | 122 | @rmdir($directory); |
123 | 123 |
|
124 | | -printf('test classes: %d, test methods: %d, changed: %d%s', count($testFilePaths), count($classMethods), $changedCount, PHP_EOL); |
125 | | -printf('CPU: %.4f s (%.3f ms/method)%s', $cpu, $cpu / count($classMethods) * 1000, PHP_EOL); |
| 124 | +printf('test classes: %d, changed: %d%s', count($classes), $changedCount, PHP_EOL); |
| 125 | +printf('CPU: %.4f s (%.3f ms/class)%s', $cpu, $cpu / count($classes) * 1000, PHP_EOL); |
126 | 126 | printf('wall: %.4f s%s', $wall, PHP_EOL); |
127 | 127 |
|
128 | 128 | if ($cpu > MAX_CPU_SECONDS) { |
|
0 commit comments