Skip to content

Commit

Permalink
Fixed bug #19655 : Closures reporting as multi-line when they are not
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Oct 26, 2012
1 parent e49952e commit 5369695
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Expand Up @@ -105,7 +105,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
}//end if }//end if


// Check if this is a single line or multi-line declaration. // Check if this is a single line or multi-line declaration.
$singleLine = false; $singleLine = true;
if ($tokens[$openBracket]['line'] === $tokens[$closeBracket]['line']) { if ($tokens[$openBracket]['line'] === $tokens[$closeBracket]['line']) {
// Closures may use the USE keyword and so be multi-line in this way. // Closures may use the USE keyword and so be multi-line in this way.
if ($tokens[$stackPtr]['code'] === T_CLOSURE) { if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
Expand All @@ -114,13 +114,13 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
// are also on the same line, this is a single line declaration. // are also on the same line, this is a single line declaration.
$open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1)); $open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1));
$close = $tokens[$open]['parenthesis_closer']; $close = $tokens[$open]['parenthesis_closer'];
if ($tokens[$open]['line'] === $tokens[$close]['line']) { if ($tokens[$open]['line'] !== $tokens[$close]['line']) {
$singleLine = true; $singleLine = false;
} }
} }
} else {
$singleLine = true;
} }
} else {
$singleLine = false;
} }


if ($singleLine === true) { if ($singleLine === true) {
Expand Down
Expand Up @@ -90,4 +90,11 @@ $noArgs_longVars = function () use (
) { ) {
// body // body
}; };

usort(
$data,
function ($a, $b) {
// body
}
);
?> ?>
1 change: 1 addition & 0 deletions package.xml
Expand Up @@ -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 #19616 : Nested switches cause false error in PSR2
- Fixed bug #19629 : PSR2 error for inline comments on multi-line argument lists - 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 #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> </notes>
<contents> <contents>
<dir name="/"> <dir name="/">
Expand Down

0 comments on commit 5369695

Please sign in to comment.