summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndrea Faulds <ajf@ajf.me>2014-09-16 19:32:01 +0100
committerAndrea Faulds <ajf@ajf.me>2014-09-16 19:32:01 +0100
commit157da54e8236f939ed79fa9f91a2c9f4dd08fc68 (patch)
tree298d144dce32d67cf5d523da099de6a54f159585 /tests
parenta1711cee1714d9cc4c4a2f18b3a45f195e5a2adf (diff)
downloadphp-git-157da54e8236f939ed79fa9f91a2c9f4dd08fc68.tar.gz
Ensure not evaluated twice
Diffstat (limited to 'tests')
-rw-r--r--tests/lang/operators/coalesce.phpt12
1 files changed, 11 insertions, 1 deletions
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