diff --git a/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index 67d6271b64..0442555e5f 100644 --- a/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -105,7 +105,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) }//end if // Check if this is a single line or multi-line declaration. - $singleLine = false; + $singleLine = true; if ($tokens[$openBracket]['line'] === $tokens[$closeBracket]['line']) { // Closures may use the USE keyword and so be multi-line in this way. if ($tokens[$stackPtr]['code'] === T_CLOSURE) { @@ -114,13 +114,13 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // are also on the same line, this is a single line declaration. $open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1)); $close = $tokens[$open]['parenthesis_closer']; - if ($tokens[$open]['line'] === $tokens[$close]['line']) { - $singleLine = true; + if ($tokens[$open]['line'] !== $tokens[$close]['line']) { + $singleLine = false; } } - } else { - $singleLine = true; } + } else { + $singleLine = false; } if ($singleLine === true) { diff --git a/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc b/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc index 1178dc6ed0..c2dbccdd49 100644 --- a/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc +++ b/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc @@ -90,4 +90,11 @@ $noArgs_longVars = function () use ( ) { // body }; + +usort( + $data, + function ($a, $b) { + // body + } +); ?> diff --git a/package.xml b/package.xml index cbc71ef592..f7de181e70 100644 --- a/package.xml +++ b/package.xml @@ -58,6 +58,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> - Fixed bug #19616 : Nested switches cause false error in PSR2 - Fixed bug #19629 : PSR2 error for inline comments on multi-line argument lists - Fixed bug #19644 : Alternative syntax, e.g. if/endif triggers Inline Control Structure error + - Fixed bug #19655 : Closures reporting as multi-line when they are not