Skip to content

Commit 1a901c9

Browse files
authored
Merge pull request #445 from PHPCSStandards/internal/isshortarrayorlist-minor-tweak
IsShortArrayOrList::walkInside(): minor efficiency tweak
2 parents 344d342 + 54b7316 commit 1a901c9

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

PHPCSUtils/Internal/IsShortArrayOrList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ private function walkInside($opener, $recursions = 0)
472472
* If we encounter a completely empty item, this must be a short list as arrays cannot contain
473473
* empty items.
474474
*/
475-
if ($item['raw'] === '') {
475+
if ($item['clean'] === '') {
476476
return self::SHORT_LIST;
477477
}
478478

Tests/Internal/IsShortArrayOrList/WalkInsideTest.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ $array = [
139139
[, $a, $b],
140140
/* testNestedShortListEmptyEntryInMiddle */
141141
[$a,, $b],
142+
/* testNestedShortListEmptyEntryInMiddleWithComment */
143+
[$a, /*empty*/, $b],
142144
/* testNestedShortListEmptyEntryAtEnd */
143145
[$a, $b, , ],
144146

Tests/Internal/IsShortArrayOrList/WalkInsideTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ public function dataWalkInsideResolved()
225225
'testMarker' => '/* testNestedShortListEmptyEntryInMiddle */',
226226
'expected' => IsShortArrayOrList::SHORT_LIST,
227227
],
228+
'nested-short-list-empty-entry-in-middle-with-comment' => [
229+
'testMarker' => '/* testNestedShortListEmptyEntryInMiddleWithComment */',
230+
'expected' => IsShortArrayOrList::SHORT_LIST,
231+
],
228232
'nested-short-list-empty-entry-at-end' => [
229233
'testMarker' => '/* testNestedShortListEmptyEntryAtEnd */',
230234
'expected' => IsShortArrayOrList::SHORT_LIST,

0 commit comments

Comments
 (0)