You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Print a hint at the end of a run when files were skipped because of errors #8966
When a rule throws on a file, Rector reports a system error and skips the whole file. Other files are still changed and the run ends as if it were complete. Nothing at the end says that the result is partial and that a re-run is needed once the cause is fixed.
Example
class Foo
{
functionFoo() {}
functionfirst($value)
{
return$value{0};
}
}
With a set like LevelSetList::UP_TO_PHP_80, Rector parses the file with its own PHP 7.0 parser, but PHPStan cannot parse $value{0}. The class is unknown to reflection, so Php4ConstructorRector threw Class "Foo" should be known at this point and the file was skipped (fixed for this case in #8965). CurlyToSquareBracketArrayStringRector could have fixed the file, but it never ran on it.
The same happens for any rule that throws on a file: the file is skipped completely and no later rule gets to change it.
Proposal
At the end of a run, if there were system errors and other files were changed in the same run, print a hint, for example:
12 files could not be processed and were skipped. Fix the cause or skip the rule, then run Rector again.
Optionally, when the cause is a parse error PHPStan cannot handle, point to a rule that may fix it.
Questions
Is a plain hint after the error list enough, or should it also appear in the JSON/other output formats?
Should it change the exit code, or stay informational?
I can open a PR for the plain text hint if this direction is fine.
Tried latest dev-main on a ~15k file legacy project with LevelSetList::UP_TO_PHP_80: errors went from 7 to 1. The 6 "should be known at this point" errors are gone, those files are processed now.
One error is left, Node "PhpParser\Node\Expr\Array_" with ... is missing scope from LongArrayToShortArrayRector on a single file. I could not reduce it to a minimal example yet (large file with many gotos).
The hint at the end of a run about skipped files would still be useful for cases like that one.
Minimal reproducer for the missing scope error: unreachable code after goto, behind a label that nothing jumps to.
<?phpgoto end;
lbl:
$a = array(1);
end:
Config: ->withRules([LongArrayToShortArrayRector::class]) (also happens with LevelSetList::UP_TO_PHP_80), on current dev-main.
Result: Node "PhpParser\Node\Expr\Array_" with is missing scope required for scope refresh, thrown from ChangedNodeScopeRefresher::refresh(). Without the label it works, with [1] instead of array(1) nothing changes so nothing is refreshed.
I can open a PR that returns early when there is no scope, if that is the direction you want.
Activity
TomasVotruba commentedon Nov 17, 2026
I just merged #8965, can you try latest rector/rector dev-main to see how it changed the report?
hmennen90 commentedon Nov 17, 2026
Tried latest dev-main on a ~15k file legacy project with
LevelSetList::UP_TO_PHP_80: errors went from 7 to 1. The 6 "should be known at this point" errors are gone, those files are processed now.One error is left,
Node "PhpParser\Node\Expr\Array_" with ... is missing scopefromLongArrayToShortArrayRectoron a single file. I could not reduce it to a minimal example yet (large file with manygotos).The hint at the end of a run about skipped files would still be useful for cases like that one.
TomasVotruba commentedon Nov 17, 2026
Great to hear!
Can you share a miniaml reproducer for the array issue via https://getrector.com/demo ? We'll be able to isolate the fix then.
hmennen90 commentedon Nov 17, 2026
Minimal reproducer for the
missing scopeerror: unreachable code aftergoto, behind a label that nothing jumps to.Config:
->withRules([LongArrayToShortArrayRector::class])(also happens withLevelSetList::UP_TO_PHP_80), on current dev-main.Result:
Node "PhpParser\Node\Expr\Array_" with is missing scope required for scope refresh, thrown fromChangedNodeScopeRefresher::refresh(). Without the label it works, with[1]instead ofarray(1)nothing changes so nothing is refreshed.I can open a PR that returns early when there is no scope, if that is the direction you want.
hmennen90 commentedon Nov 17, 2026
Here is the demo link: https://getrector.com/demo/cf0229bf-0b5f-4d45-a6b2-2d7322d7cb85
samsonasik commentedon Nov 17, 2026
I created PR:
for it.