[ticket/16671] Do not allow leading backslashes in use statements

PHPBB3-16671
This commit is contained in:
Máté Bartus 2020-12-31 14:49:49 +01:00
parent 8830354555
commit 3d8f7ee33b

View file

@ -86,6 +86,11 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements Sniff
$class_name_short = $tokens[$class_name_end - 1]['content']; $class_name_short = $tokens[$class_name_end - 1]['content'];
} }
if ($class_name_full[0] === '\\')
{
$phpcsFile->addError("There must not be a leading '\\' in use statements.", $stackPtr, 'Malformed');
}
$ok = false; $ok = false;
// Checks in simple statements (new, instanceof and extends) // Checks in simple statements (new, instanceof and extends)