From 157da54e8236f939ed79fa9f91a2c9f4dd08fc68 Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Tue, 16 Sep 2014 19:32:01 +0100 Subject: Ensure not evaluated twice --- tests/lang/operators/coalesce.phpt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/lang/operators/coalesce.phpt b/tests/lang/operators/coalesce.phpt index 30571d484e..327a11a432 100644 --- a/tests/lang/operators/coalesce.phpt +++ b/tests/lang/operators/coalesce.phpt @@ -19,6 +19,11 @@ $arr = [ ] ]; +function foobar() { + echo "called\n"; + return ['a']; +} + var_dump($nonexistant_variable ?? 3); echo PHP_EOL; var_dump($var ?? 3); @@ -35,6 +40,8 @@ var_dump($arr["foobar"] ?? 3); var_dump($arr["qux"] ?? 3); var_dump($arr["bing"][0] ?? 3); var_dump($arr["bing"][1] ?? 3); +echo PHP_EOL; +var_dump(foobar()[0] ?? false); ?> --EXPECTF-- int(3) @@ -55,4 +62,7 @@ object(stdClass)#%d (%d) { int(7) } string(4) "bang" -int(3) \ No newline at end of file +int(3) + +called +string(1) "a" \ No newline at end of file -- cgit v1.2.1