diff options
author | Tristan Darricau <github@nicofuma.fr> | 2014-07-12 16:55:14 +0200 |
---|---|---|
committer | Tristan Darricau <github@nicofuma.fr> | 2014-07-12 16:55:14 +0200 |
commit | 57f7fdf989aea59d2f8cb853546574fc1885d049 (patch) | |
tree | 71f5bd38c2ee4f2cd8a87f95bcac210d4e0c7857 | |
parent | dd78b564e56152be559b4ec476e35698fa32e1bf (diff) | |
download | forums-57f7fdf989aea59d2f8cb853546574fc1885d049.tar forums-57f7fdf989aea59d2f8cb853546574fc1885d049.tar.gz forums-57f7fdf989aea59d2f8cb853546574fc1885d049.tar.bz2 forums-57f7fdf989aea59d2f8cb853546574fc1885d049.tar.xz forums-57f7fdf989aea59d2f8cb853546574fc1885d049.zip |
[ticket/12842] Skip parameters without exlicit type
PHPBB3-12842
-rw-r--r-- | build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php index 16e3427bd9..f81ec46579 100644 --- a/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php +++ b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php @@ -153,19 +153,24 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff $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_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)); - - if ($argument_class_name === $class_name_full) + // Skip the parameter if no type is defined. + if ($argument_class_name_start !== false) { - $error = 'Either use statement or full name must be used.'; - $phpcsFile->addError($error, $function_declaration, 'FullName'); - } + $argument_class_name_end = $phpcsFile->findNext($find, ($argument_class_name_start + 1), null, true); - if ($argument_class_name === $class_name_short) - { - $ok = true; + $argument_class_name = $phpcsFile->getTokensAsString($argument_class_name_start, ($argument_class_name_end - $argument_class_name_start - 1)); + + 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; + } } } } |