UnnecessarySemicolon
info on by default quick-fixGroup: Code style · PhpStorm name: UnnecessarySemicolonInspection
Stray semicolons — empty statements and the terminator right before ?> in a short echo tag — add nothing and are usually typos. Remove them.
Example
php
<?php
declare(ticks=1);
for ($i = 0; $i < 3; $i++) ;
while (next($items)) ;
do ; while (false);
if ($ready) ;
elseif ($late) ;
else ;
function tidy() {
prepare();;
;
return;
}
class Box {};
?>
<p><?= $title; ?></p>
<p><?= $title; $title = null; ?></p>
<p><?php show($title); ?></p>php
<?php
declare(ticks=1);
for ($i = 0; $i < 3; $i++) ;
while (next($items)) ;
do ; while (false);
if ($ready) ;
elseif ($late) ;
else ;
function tidy() {
prepare();
return;
}
class Box {}
?>
<p><?= $title ?></p>
<p><?= $title; $title = null; ?></p>
<p><?php show($title); ?></p>Reported:
- line 12: Stray semicolon; remove it.
- line 13: Stray semicolon; remove it.
- line 16: Stray semicolon; remove it.
- line 18: Stray semicolon; remove it.
Configure
In custos.json:
json
{
"rules": {
"UnnecessarySemicolon": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore UnnecessarySemicolon
/**
* @noinspection UnnecessarySemicolonInspection
*/