UnusedGotoLabel
info on by default quick-fixGroup: Unused · PhpStorm name: UnusedGotoLabelInspection
A goto label that no goto statement targets is dead code; it only suggests control flow that does not exist. Remove it.
Example
php
<?php
function retry_job($job)
{
$attempts = 0;
again:
done:
Again:
if (!$job->run() && ++$attempts < 3) {
goto again;
}
$cleanup = function () {
finish:
return true;
goto finish;
};
}
start:
echo "top level";php
<?php
function retry_job($job)
{
$attempts = 0;
again:
if (!$job->run() && ++$attempts < 3) {
goto again;
}
$cleanup = function () {
finish:
return true;
goto finish;
};
}
start:
echo "top level";Reported:
- line 6: Label 'done' is never targeted by a goto; remove it.
- line 7: Label 'Again' is never targeted by a goto; remove it.
Configure
In custos.json:
json
{
"rules": {
"UnusedGotoLabel": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore UnusedGotoLabel
/**
* @noinspection UnusedGotoLabelInspection
*/