Hey, I've upgraded to the latest Rector and now when I run the same command on the same code base as before then it times out after 1 hour 23 minutes 20 seconds:
composer rector -- --dry-run
> bin/rector process --config rector.php '--dry-run'
Rector 0.8.52
Config file: rector.php
2769/9112 [鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒] 30%
[Symfony\Component\Process\Exception\ProcessTimedOutException]
The process "bin/rector process --config rector.php '--dry-run'" exceeded the timeout of 5000 seconds.
It takes 1 minute 49 seconds on version 0.6.13. See https://github.com/mautic/mautic/runs/1386226195
Is this normal?
Hi, there is some loop in your project.
Check CI Actions here.
It usually takes 3-6 minutes for ~9000 steps.
Try narrowing it down to specific file and rule by scoping.
@escopecz you can try with --debug to see what file and rule that take long to execute.
@samsonasik That helped!
[parsing] plugins/MauticCloudStorageBundle/Form/Type/RackspaceType.php
Fatal error: Uncaught _HumbugBox9a2b3b20a128\Symfony\Component\Filesystem\Exception\IOException: Failed to read "/var/www/html/plugins/MauticCloudStorageBundle/Form/Type/RackspaceType.php" file: "" in phar:///var/www/html/vendor/rector/rector-prefixed/rector/vendor/symplify/smart-file-system/src/SmartFileSystem.php:25
Stack trace:
#0 phar:///var/www/html/vendor/rector/rector-prefixed/rector/src/PhpParser/Parser/Parser.php(39): Symplify\SmartFileSystem\SmartFileSystem->readFile('/var/www/html/p...')
#1 phar:///var/www/html/vendor/rector/rector-prefixed/rector/src/Application/FileProcessor.php(130): Rector\Core\PhpParser\Parser\Parser->parseFileInfo(Object(Symplify\SmartFileSystem\SmartFileInfo))
#2 phar:///var/www/html/vendor/rector/rector-prefixed/rector/src/Application/FileProcessor.php(81): Rector\Core\Application\FileProcessor->parseAndTraverseFileInfoToNodes(Object(Symplify\SmartFileSystem\SmartFileInfo))
#3 phar:///var/www/html/vendor/rector/rector-prefixed/rector/src/Application/RectorApplication.php(169): Rector\Co in phar:///var/www/html/vendor/rector/rector-prefixed/rector/vendor/symplify/smart-file-system/src/SmartFileSystem.php on line 25
Script bin/rector process --config rector.php handling the rector event returned with error code 255
The file RackspaceType.php was completely empty. It should not exist but was resurrected by a bad merge.
However, it is still very slow. I'm looking at the progressbar right now. It takes ~20 seconds to process 1 file and I'm only 25% in. Is there any tip how to speed it up?
When I run in debug again I get this:
[refactoring] app/bundles/ApiBundle/Controller/CommonApiController.php
[applying] Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector
[applying] Rector\DeadCode\Rector\Class_\RemoveUnusedDoctrineEntityMethodAndPropertyRector
[applying] Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector
[applying] Rector\DeadCode\Rector\Property\RemoveSetterOnlyPropertyAndMethodCallRector
[applying] Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector
[applying] Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector
[applying] Rector\DeadCode\Rector\FunctionLike\RemoveOverriddenValuesRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector
[applying] Rector\DeadCode\Rector\FunctionLike\RemoveCodeAfterReturnRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector
[applying] Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector
[applying] Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector
[applying] Rector\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector
[applying] Rector\DeadCode\Rector\ClassMethod\RemoveDeadRecursiveClassMethodRector
[applying] Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector
[applying] Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector
[applying] Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector
[applying] Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector
[applying] Rector\DeadCode\Rector\Assign\RemoveAssignOfVoidReturnFunctionRector
[applying] Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector
[applying] Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector
[applying] Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector
[applying] Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector
[applying] Rector\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector
[applying] Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector
[applying] Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector
[applying] Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector
[applying] Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector
[applying] Rector\RectorGenerator\Rector\Closure\AddNewServiceToSymfonyPhpConfigRector
Fatal error: Uncaught Rector\Core\Exception\ShouldNotHappenException: Node "PhpParser\Node\Expr\MethodCall" is child of "PhpParser\Node\Expr\Assign", so it cannot be removed as it would break PHP code. Change or remove the parent node instead. in phar:///var/www/html/vendor/rector/rector-prefixed/rector/packages/node-removal/src/BreakingRemovalGuard.php:22
Stack trace:
#0 phar:///var/www/html/vendor/rector/rector-prefixed/rector/packages/post-rector/src/Collector/NodesToRemoveCollector.php(44): Rector\NodeRemoval\BreakingRemovalGuard->ensureNodeCanBeRemove(Object(PhpParser\Node\Expr\MethodCall))
#1 phar:///var/www/html/vendor/rector/rector-prefixed/rector/packages/post-rector/src/Rector/AbstractRector/NodeCommandersTrait.php(151): Rector\PostRector\Collector\NodesToRemoveCollector->addNodeToRemove(Object(PhpParser\Node\Expr\MethodCall))
#2 phar:///var/www/html/vendor/rector/rector-prefixed/rector/rules/dead-code/src/Rector/MethodCall/RemoveEmptyMethodCallRector.php(92): Rector\Core\Rector\AbstractRector->removeNode(Object in phar:///var/www/html/vendor/rector/rector-prefixed/rector/packages/node-removal/src/BreakingRemovalGuard.php on line 22
Script bin/rector process --config rector.php handling the rector event returned with error code 255
It looks like a PhpParser issue, right?
Here is the problematic file: https://github.com/alanhartless/mautic/blob/m4-quick-and-dirty/app/bundles/ApiBundle/Controller/CommonApiController.php
Good job :+1:
That's bug in one of Rector rules. Now we only need minimal broken code from CommonApiController,
then add it to AddNewServiceToSymfonyPhpConfigRectorTest battery.
In the end it will be 1 line, from error it's a method call that is part of an assign:
$some = $this->someMethod();
When you find the broken line, here is how to add test case: https://github.com/rectorphp/rector/blob/master/docs/how_to_add_test_for_rector_rule.md
I'll fix it then
There is 189 occurrences in that file. Isn't there an option how to rule some out? I thought it could be this:

But when I implemented that method in the Abstract model it fails the same way.
The fastest way for me is comment half of the file. If it works, it's in the commented part. If not, I comment another half down with same process...
On the other hand.... I wonder, maybe Rector could report the line of the node that is causing this.
In the meantime, you can go to BreakingRemovalGuard.php:22 and dump the $node->getLine() (or similar, the PHPStorm will tell) to see the line it is on.
This might help: https://github.com/rectorphp/rector/pull/4703/files#diff-5cd7cb5e17a1ae325b77050cf7f0b777e0671d5f0429394f0488993b2a7ec72d
Soon to be merged in master