return
PHP-W1074The return
keyword ends the function execution. If return
is used outside of a function, it stops PHP code in the file from running.
Therefore, any code after return
is considered as dead code as it won't be executed ever and can be safely removed.
function getSlug(string $title): string {
$array = explode(' ', strtolower($title));
return implode('-', $array);
unset($array); // invalid: this code will never executed
}
Make sure there's no code after return
statement:
function getSlug(string $title): string {
$array = explode(' ', strtolower($title));
return implode('-', $array);
}