Skip to content

Commit

Permalink
Added missing unit tests for #3061
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Sep 21, 2020
1 parent 1100d89 commit af12525
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,11 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array

$valuePointer = $value['value'];

$ignoreTokens = ([
$ignoreTokens = [
T_WHITESPACE => T_WHITESPACE,
T_COMMA => T_COMMA,
] + Tokens::$castTokens);
];
$ignoreTokens += Tokens::$castTokens;

if ($tokens[$valuePointer]['code'] === T_CLOSURE) {
$ignoreTokens += [T_STATIC => T_STATIC];
Expand Down
13 changes: 13 additions & 0 deletions src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,19 @@ $c);
array('a' => $a, 'b' => $b,
'c' => $c);

array()
static function() {
return null;
},
(array) array(),
(bool) array(),
(double) array(),
(int) array(),
(object) array(),
(string) array(),
(unset) array(),
);

// Intentional syntax error.
$a = array(
'a' =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,19 @@ array(
'c' => $c,
);

array()
static function() {
return null;
},
(array) array(),
(bool) array(),
(double) array(),
(int) array(),
(object) array(),
(string) array(),
(unset) array(),
);

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

2 comments on commit af12525

@jrfnl
Copy link
Contributor

@jrfnl jrfnl commented on af12525 Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsherwood - the array() (including close brace) on line 450 looks like a parse error to me which would prevent the fix from being tested.

@gsherwood
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 🙏

Please sign in to comment.