Skip to content

Commit ede393c

Browse files
committed
Update bench to pass Class_ nodes
1 parent 9f1ac63 commit ede393c

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎bench/does_not_perform_assertion_lifecycle_bench.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Run on both branches to compare. CPU (user+sys) is the reliable metric; wall is noisy.
1212
*/
1313

14-
use PhpParser\Node\Stmt\ClassMethod;
14+
use PhpParser\Node\Stmt\Class_;
1515
use Rector\DependencyInjection\LazyContainerFactory;
1616
use Rector\PhpParser\Node\BetterNodeFinder;
1717
use Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector;
@@ -99,10 +99,10 @@
9999
$rector = $rectorConfig->make(AddDoesNotPerformAssertionToNonAssertingTestRector::class);
100100

101101
// parse test files up front, parent files are left for the rule to resolve
102-
$classMethods = [];
102+
$classes = [];
103103
foreach ($testFilePaths as $testFilePath) {
104104
$stmts = $testingParser->parseFileToDecoratedNodes($testFilePath);
105-
$classMethods = [...$classMethods, ...$betterNodeFinder->findInstanceOf($stmts, ClassMethod::class)];
105+
$classes = [...$classes, ...$betterNodeFinder->findInstanceOf($stmts, Class_::class)];
106106
}
107107

108108
$cpuSeconds = static function (): float {
@@ -115,8 +115,8 @@
115115
$cpuStart = $cpuSeconds();
116116

117117
$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_) {
120120
++$changedCount;
121121
}
122122
}
@@ -127,8 +127,8 @@
127127
array_map('unlink', glob($directory . '/*.php'));
128128
@rmdir($directory);
129129

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);
132132
printf('wall: %.4f s%s', $wall, PHP_EOL);
133133

134134
if ($cpu > MAX_CPU_SECONDS) {

0 commit comments

Comments
 (0)