rector
rector copied to clipboard
Incorrect behavior of AddDefaultValueForUndefinedVariableRector with exit conditions
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.org/demo/97de3515-aaf6-4cfd-8b67-5f26776fa190
<?php
final class DemoFile
{
public function run()
{
exit();
$test = true;
return $test;
}
}
Responsible rules
-
AddDefaultValueForUndefinedVariableRector
Expected Behavior
It should not add code if an exit condition is detected.
Same issue pops up in our phpunit tests that have:
$this->markTestSkipped('todo fix later');
which is a function that calls:
throw new SkippedTestError($message);