Skip to content

Commit

Permalink
Fixed an issue in Generic FunctionCallArgumentSpacingSniff where clos…
Browse files Browse the repository at this point in the history
…ures could cause incorrect errors
  • Loading branch information
gsherwood committed Apr 23, 2012
1 parent 21bb0ea commit 2a63cf7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$closeBracket = $tokens[$openBracket]['parenthesis_closer'];

$nextSeperator = $openBracket;
while (($nextSeperator = $phpcsFile->findNext(array(T_COMMA, T_VARIABLE), ($nextSeperator + 1), $closeBracket)) !== false) {
while (($nextSeperator = $phpcsFile->findNext(array(T_COMMA, T_VARIABLE, T_CLOSURE), ($nextSeperator + 1), $closeBracket)) !== false) {
if ($tokens[$nextSeperator]['code'] === T_CLOSURE) {
$nextSeperator = $tokens[$nextSeperator]['scope_closer'];
continue;
}

// Make sure the comma or variable belongs directly to this function call,
// and is not inside a nested function call or array.
$brackets = $tokens[$nextSeperator]['nested_parenthesis'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,13 @@ class MyClass {
function &myFunction($arg1=1,$arg2=2)
{
}

return array_udiff(
$foo,
$bar,
function($a, $b) {
$foo='bar';
return $foo;
}
);
?>
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed an issue in AbstractPatternSniff where comments were not being ignored in some cases
- Fixed an issue in Zend ClosingTagSniff where the closing tag was not always being detected correctly
-- Thanks to Jonathan Robson for the patch
- Fixed an issue in Generic FunctionCallArgumentSpacingSniff where closures could cause incorrect errors
- Fixed bug #19290 : Generic indent sniffer fails for anonymous functions
- Fixed bug #19324 : Setting show_warnings configuration option does not work
- Fixed bug #19354 : Not recognizing references passed to method
Expand Down

0 comments on commit 2a63cf7

Please sign in to comment.