--TEST--
Bug 76337: segmentation fault when an extension use zend_register_class_alias() and opcache enabled
--SKIPIF--
-<?php if (!class_exists('_ZendTestClass') || !extension_loaded('Zend OPcache')) die('skip');
++<?php require_once('skipif.inc'); ?>
+<?php if (!extension_loaded('zend-test')) die('skip zend-test extension not loaded');
--INI--
opcache.enable=1
opcache.enable_cli=1
--- /dev/null
+--TEST--
+Bug #77257: value of variable assigned in a switch() construct gets lost
++--SKIPIF--
++<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function test($x) {
+ $a = false;
+ switch($x["y"]) {
+ case "a":
+ $a = true;
+ break;
+ case "b":
+ break;
+ case "c":
+ break;
+ }
+ return $a;
+}
+var_dump(test(["y" => "a"]));
+?>
+--EXPECT--
+bool(true)
--- /dev/null
+--TEST--
+Bug #77275: OPcache optimization problem for ArrayAccess->offsetGet(string)
+--INI--
+opcache.enable_cli=1
+opcache.optimization_level=-1
++--SKIPIF--
++<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+namespace Foo;
+class Bar { public function get() {} }
+class Record implements \ArrayAccess {
+ public function offsetSet($offset, $value) { throw new \Exception; }
+ public function offsetGet($offset) { var_dump($offset); }
+ public function offsetExists($offset) { throw new \Exception; }
+ public function offsetUnset($offset) { throw new \Exception; }
+}
+class Baz {
+ public function run() {
+ $a = pow(1, 2);
+ $b = new Bar();
+ $c = new Bar();
+ $d = new Bar();
+ $id = $b->get('a', 'b', 'c');
+ $rec = new Record();
+ $id = $rec['a'];
+ }
+}
+(new Baz())->run();
+?>
+--EXPECT--
+string(1) "a"
--- /dev/null
+--TEST--
+Bug #77310 (1): Incorrect SCCP for compound assign to arrays
++--SKIPIF--
++<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+function breakit($data_arr) {
+ $foo[0] = "";
+ for ($i = 0; $i < count($data_arr); $i++) {
+ $foo[0] .= $data_arr[$i];
+ }
+ echo $foo[0] . "\n";
+}
+
+$data = ['zero', 'one', 'two'];
+breakit($data);
+
+?>
+--EXPECT--
+zeroonetwo
--- /dev/null
+--TEST--
+Bug #78015: Incorrect evaluation of expressions involving partials array in SCCP
++--SKIPIF--
++<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$x = 1;
+
+function test1() {
+ global $x;
+ $a = ['b' => [$x], 'c' => [$x]];
+ $d = $a['b'] + $a['c'];
+ return $d;
+}
+
+function test2() {
+ global $x;
+ $a = ['b' => [$x]];
+ $d = !$a['b'];
+ return $d;
+}
+
+function test3() {
+ global $x;
+ $a = ['b' => [$x]];
+ $d = (int) $a['b'];
+ return $d;
+}
+
+function test4() {
+ global $x;
+ $a = ['b' => [$x]];
+ $d = $a['b'] ?: 42;
+ return $d;
+}
+
+function test5() {
+ global $x;
+ $a = ['b' => [$x]];
+ $d = is_array($a['b']);
+ return $d;
+}
+
+function test6() {
+ global $x;
+ $a = ['b' => [$x]];
+ $b = "foo";
+ $d = "$a[b]{$b}bar";
+ return $d;
+}
+
+function test7() {
+ global $x;
+ $a = ['b' => [$x]];
+ $y = 1;
+ foreach ($a['b'] as $_) {
+ $y = 2;
+ }
+ return $y;
+}
+
+function test8($array) {
+ $i = 0;
+ $ret = [[]];
+ foreach ($array as $_) {
+ $i++;
+ $ret = [[
+ 'x' => 0,
+ 'y' => $i,
+ ]];
+ }
+ return $ret[0];
+}
+
+function test9() {
+ global $x;
+ $a = ['b' => [$x]];
+ return serialize($a['b']);
+}
+
+var_dump(test1());
+var_dump(test2());
+var_dump(test3());
+var_dump(test4());
+var_dump(test5());
+var_dump(test6());
+var_dump(test7());
+var_dump(test8([1]));
+var_dump(test9());
+
+?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ int(1)
+}
+bool(false)
+int(1)
+array(1) {
+ [0]=>
+ int(1)
+}
+bool(true)
+
+Notice: Array to string conversion in %s on line %d
+string(11) "Arrayfoobar"
+int(2)
+array(2) {
+ ["x"]=>
+ int(0)
+ ["y"]=>
+ int(1)
+}
+string(14) "a:1:{i:0;i:1;}"
--- /dev/null
+--TEST--
+Throwings NEWs should not be DCEd
+--INI--
+opcache.enable_cli=1
+opcache.optimization_level=-1
++--SKIPIF--
++<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+abstract class Foo {}
+interface Bar {}
+trait Baz {}
+
+class Abc {
+ const BAR = Abc::BAR;
+}
+
+function test1() {
+ $x = new Foo;
+}
+function test2() {
+ $x = new Bar;
+}
+function test3() {
+ $x = new Baz;
+}
+function test4() {
+ $x = new Abc;
+}
+
+try { test1(); } catch (Error $e) { echo $e->getMessage(), "\n"; }
+try { test2(); } catch (Error $e) { echo $e->getMessage(), "\n"; }
+try { test3(); } catch (Error $e) { echo $e->getMessage(), "\n"; }
+try { test4(); } catch (Error $e) { echo $e->getMessage(), "\n"; }
+
+?>
+--EXPECT--
+Cannot instantiate abstract class Foo
+Cannot instantiate interface Bar
+Cannot instantiate trait Baz
+Cannot declare self-referencing constant 'Abc::BAR'
--- /dev/null
+--TEST--
+Incorrect empty basic block elimination
+--INI--
+opcache.enable_cli=1
+opcache.optimization_level=-1
++--SKIPIF--
++<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+function test() {
+ $foo = "test";
+ var_dump($foo ?? "default");
+
+ $null = null;
+ var_dump($null ?? 3);
+ var_dump($null ?? new stdClass);
+}
+test();
+
+?>
+--EXPECT--
+string(4) "test"
+int(3)
+object(stdClass)#1 (0) {
+}
--- /dev/null
+--TEST--
+Wrong assertion
++--SKIPIF--
++<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function foo($transitions) {
+ foreach ($transitions as $transition) {
+ if (isEmpty()) {
+ continue;
+ }
+ }
+}
+?>
+OK
+--EXPECT--
+OK