Skip to content

Commit f3abf41

Browse files
committed
test non-nullable last element
1 parent 955e801 commit f3abf41

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/PHPStan/Analyser/nsrt/bug-14213.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,24 @@ public static function coalesce_int_range_after_maybe_defined(): void
4545

4646
assertType('10|int<0, 5>|null', $x);
4747
}
48+
49+
public static function coalesce_int_range_with_last_nullable(): void
50+
{
51+
$x0 = $x1 = null;
52+
$x2 = 20;
53+
54+
if (rand(0, 1)) {
55+
$x0 = rand(0, 1);
56+
$x1 = rand(2, 3);
57+
$x2 = rand(4, 5);
58+
}
59+
60+
$x = (
61+
$x0 ??
62+
$x1 ??
63+
$x2 // cannot be null
64+
);
65+
66+
assertType('20|int<0, 5>', $x);
67+
}
4868
}

0 commit comments

Comments
 (0)