mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/12842] Skip parameters without exlicit type
PHPBB3-12842
This commit is contained in:
parent
dd78b564e5
commit
57f7fdf989
1 changed files with 15 additions and 10 deletions
|
@ -153,19 +153,24 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
|
||||||
|
|
||||||
$start_argument = $phpcsFile->findPrevious(array(T_OPEN_PARENTHESIS, T_COMMA), $argument);
|
$start_argument = $phpcsFile->findPrevious(array(T_OPEN_PARENTHESIS, T_COMMA), $argument);
|
||||||
$argument_class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), ($start_argument + 1), $argument);
|
$argument_class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), ($start_argument + 1), $argument);
|
||||||
$argument_class_name_end = $phpcsFile->findNext($find, ($argument_class_name_start + 1), null, true);
|
|
||||||
|
|
||||||
$argument_class_name = $phpcsFile->getTokensAsString($argument_class_name_start, ($argument_class_name_end - $argument_class_name_start - 1));
|
// Skip the parameter if no type is defined.
|
||||||
|
if ($argument_class_name_start !== false)
|
||||||
if ($argument_class_name === $class_name_full)
|
|
||||||
{
|
{
|
||||||
$error = 'Either use statement or full name must be used.';
|
$argument_class_name_end = $phpcsFile->findNext($find, ($argument_class_name_start + 1), null, true);
|
||||||
$phpcsFile->addError($error, $function_declaration, 'FullName');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($argument_class_name === $class_name_short)
|
$argument_class_name = $phpcsFile->getTokensAsString($argument_class_name_start, ($argument_class_name_end - $argument_class_name_start - 1));
|
||||||
{
|
|
||||||
$ok = true;
|
if ($argument_class_name === $class_name_full)
|
||||||
|
{
|
||||||
|
$error = 'Either use statement or full name must be used.';
|
||||||
|
$phpcsFile->addError($error, $function_declaration, 'FullName');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($argument_class_name === $class_name_short)
|
||||||
|
{
|
||||||
|
$ok = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue