squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.67k stars 1.48k forks source link

Squiz FunctionDeclarationArgumentSpacing gives incorrect error when first arg is a variadic #1034

Closed firegate666 closed 8 years ago

firegate666 commented 8 years ago

I have the following function

function o(...$args) {
    $args_len = sizeof($args);
    ...
}

which should be valid, but the code sniffers complains about it

 51 | ERROR | [x] Expected 1 space between type hint and argument
 |       |     "$args"; 0 found
 |       |     (Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint)

Within the same file, there is a similar method that uses the variadic parameter as second parameter

function p($text, ...$arguments) {
    $text = call_user_func_array('vsprintf', [$text, $arguments]);
    print $text;
    print PHP_EOL;
}

no complains here

gsherwood commented 8 years ago

Fixed now. Thanks for reporting.

firegate666 commented 8 years ago

Awesome, thx for fixing it.