Skip to content

Commit

Permalink
Fixed alignment false positive when using arrow function as a array v…
Browse files Browse the repository at this point in the history
…alue (ref #2703, #2523)
  • Loading branch information
gsherwood committed Nov 19, 2019
1 parent 15acf50 commit 282306f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
if ($tokens[$nextToken]['code'] === T_ARRAY
|| $tokens[$nextToken]['code'] === T_OPEN_SHORT_ARRAY
|| $tokens[$nextToken]['code'] === T_CLOSURE
|| $tokens[$nextToken]['code'] === T_FN
) {
// Let subsequent calls of this test handle nested arrays.
if ($tokens[$lastToken]['code'] !== T_DOUBLE_ARROW) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ $array = array(
fn() => return 2,
);

$array = array(
1 => '1',
2 => fn ($x) => yield 'a' => $x,
3 => '3',
);

// Intentional syntax error.
$a = array(
'a' =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ $array = array(
fn() => return 2,
);

$array = array(
1 => '1',
2 => fn ($x) => yield 'a' => $x,
3 => '3',
);

// Intentional syntax error.
$a = array(
'a' =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ $array = [
fn() => return 2,
];

$array = [
1 => '1',
2 => fn ($x) => yield 'a' => $x,
3 => '3',
];

// Intentional syntax error.
$a = [
'a' =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@ $array = [
fn() => return 2,
];

$array = [
1 => '1',
2 => fn ($x) => yield 'a' => $x,
3 => '3',
];

// Intentional syntax error.
$a = [
'a' =>
Expand Down

0 comments on commit 282306f

Please sign in to comment.