]> granicus.if.org Git - php/commitdiff
Ensure not evaluated twice
authorAndrea Faulds <ajf@ajf.me>
Tue, 16 Sep 2014 18:32:01 +0000 (19:32 +0100)
committerAndrea Faulds <ajf@ajf.me>
Tue, 16 Sep 2014 18:32:01 +0000 (19:32 +0100)
tests/lang/operators/coalesce.phpt

index 30571d484e3c50e55e71788292d460f7eb059797..327a11a432353b0b05fa97bb03fff7e8c06d0a12 100644 (file)
@@ -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