Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed bug #19655 : Closures reporting as multi-line when they are not

  • Loading branch information...
commit 53696950ac850628d90c217a05ba2565dd380b0f 1 parent e49952e
@gsherwood gsherwood authored
View
10 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) {
View
7 CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc
@@ -90,4 +90,11 @@ $noArgs_longVars = function () use (
) {
// body
};
+
+usort(
+ $data,
+ function ($a, $b) {
+ // body
+ }
+);
?>
View
1  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
</notes>
<contents>
<dir name="/">
Please sign in to comment.
Something went wrong with that request. Please try again.