Skip to content

Commit

Permalink
Fixed bug #1870 : Invalid warning in multiple assignments alignment w…
Browse files Browse the repository at this point in the history
…ith closure or anon class
  • Loading branch information
gsherwood committed Jan 31, 2018
1 parent 8f108e3 commit f65239d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- Thanks to Juliette Reinders Folmer for the patch
- Fixed bug #1840 : When a comment has too many asterisks, phpcbf gives FAILED TO FIX error
- Fixed bug #1867 : Cant use phpcs:ignore where the next line is HTML
- Fixed bug #1870 : Invalid warning in multiple assignments alignment with closure or anon class
</notes>
<contents>
<dir name="/">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ public function checkAlignment($phpcsFile, $stackPtr)

for ($assign = $stackPtr; $assign < $phpcsFile->numTokens; $assign++) {
if (isset($find[$tokens[$assign]['code']]) === false) {
if ($tokens[$assign]['code'] === T_CLOSURE
|| $tokens[$assign]['code'] === T_ANON_CLASS
) {
$assign = $tokens[$assign]['scope_closer'];
$lastCode = $assign;
continue;
}

// A blank line indicates that the assignment block has ended.
if (isset(Tokens::$emptyTokens[$tokens[$assign]['code']]) === false) {
if (($tokens[$assign]['line'] - $tokens[$lastCode]['line']) > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,19 @@ $bar = 'hi';
$foo = $moo = $test;
$boo = 'boo';
$foo = $moooo = 'foo';

$foobarbaz = array_map(
function ($n) {
return $n * $n;
},
[1, 2, 3]
);
$foo = 5;

$loggerResult = $util->setLogger(new class {
public function log($msg)
{
echo $msg;
}
});
$foo = 5;
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,19 @@ $bar = 'hi';
$foo = $moo = $test;
$boo = 'boo';
$foo = $moooo = 'foo';

$foobarbaz = array_map(
function ($n) {
return $n * $n;
},
[1, 2, 3]
);
$foo = 5;

$loggerResult = $util->setLogger(new class {
public function log($msg)
{
echo $msg;
}
});
$foo = 5;

0 comments on commit f65239d

Please sign in to comment.