Skip to content

Commit 7d05628

Browse files
committed
dont narrow empty array
1 parent 1dfe071 commit 7d05628

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/PHPStan/Analyser/nsrt/list-count2.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,25 @@ function sayEqualArrayShapeAfterNarrowedCount($arrA, array $arrB): void
119119
assertType('non-empty-list', $arrB);
120120
}
121121

122+
/**
123+
* @param non-empty-array $arrB
124+
*/
125+
function dontNarrowEmpty(array $arrB): void
126+
{
127+
$arrA = [];
128+
assertType('array{}', $arrA);
129+
130+
if (count($arrA) == count($arrB)) {
131+
assertType('*NEVER*', $arrA);
132+
assertType('non-empty-array', $arrB);
133+
}
134+
assertType('array{}', $arrA);
135+
136+
if (count($arrB) == count($arrA)) {
137+
assertType('*NEVER*', $arrA);
138+
assertType('non-empty-array', $arrB);
139+
}
140+
assertType('array{}', $arrA);
141+
}
142+
122143
}

0 commit comments

Comments
 (0)