|
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; |
|
99 | 99 | $rector = $rectorConfig->make(AddDoesNotPerformAssertionToNonAssertingTestRector::class); |
100 | 100 |
|
101 | 101 | // parse test files up front, parent files are left for the rule to resolve |
102 | | -$classMethods = []; |
| 102 | +$classes = []; |
103 | 103 | foreach ($testFilePaths as $testFilePath) { |
104 | 104 | $stmts = $testingParser->parseFileToDecoratedNodes($testFilePath); |
105 | | - $classMethods = [...$classMethods, ...$betterNodeFinder->findInstanceOf($stmts, ClassMethod::class)]; |
| 105 | + $classes = [...$classes, ...$betterNodeFinder->findInstanceOf($stmts, Class_::class)]; |
106 | 106 | } |
107 | 107 |
|
108 | 108 | $cpuSeconds = static function (): float { |
|
115 | 115 | $cpuStart = $cpuSeconds(); |
116 | 116 |
|
117 | 117 | $changedCount = 0; |
118 | | -foreach ($classMethods as $classMethod) { |
119 | | - if ($rector->refactor($classMethod) instanceof ClassMethod) { |
| 118 | +foreach ($classes as $class) { |
| 119 | + if ($rector->refactor($class) instanceof Class_) { |
120 | 120 | ++$changedCount; |
121 | 121 | } |
122 | 122 | } |
|
127 | 127 | array_map('unlink', glob($directory . '/*.php')); |
128 | 128 | @rmdir($directory); |
129 | 129 |
|
130 | | -printf('test classes: %d, test methods: %d, changed: %d%s', count($testFilePaths), count($classMethods), $changedCount, PHP_EOL); |
131 | | -printf('CPU: %.4f s (%.3f ms/method)%s', $cpu, $cpu / count($classMethods) * 1000, PHP_EOL); |
| 130 | +printf('test classes: %d, changed: %d%s', count($classes), $changedCount, PHP_EOL); |
| 131 | +printf('CPU: %.4f s (%.3f ms/class)%s', $cpu, $cpu / count($classes) * 1000, PHP_EOL); |
132 | 132 | printf('wall: %.4f s%s', $wall, PHP_EOL); |
133 | 133 |
|
134 | 134 | if ($cpu > MAX_CPU_SECONDS) { |
|
0 commit comments