Skip to content

Commit ec39802

Browse files
Extended coalesce operator test case for ordering/short-circuiting
1 parent 157da54 commit ec39802

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/lang/operators/coalesce.phpt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ var_dump($arr["bing"][0] ?? 3);
4242
var_dump($arr["bing"][1] ?? 3);
4343
echo PHP_EOL;
4444
var_dump(foobar()[0] ?? false);
45+
echo PHP_EOL;
46+
function f($x)
47+
{
48+
printf("%s(%d)\n", __FUNCTION__, $x);
49+
return $x;
50+
}
51+
52+
$a = f(null) ?? f(1) ?? f(2);
4553
?>
4654
--EXPECTF--
4755
int(3)
@@ -65,4 +73,7 @@ string(4) "bang"
6573
int(3)
6674

6775
called
68-
string(1) "a"
76+
string(1) "a"
77+
78+
f(0)
79+
f(1)

0 commit comments

Comments
 (0)