xref: /PHP-7.4/ext/opcache/tests/bug77275.phpt (revision 93aabf15)
1--TEST--
2Bug #77275: OPcache optimization problem for ArrayAccess->offsetGet(string)
3--INI--
4opcache.enable_cli=1
5opcache.optimization_level=-1
6--SKIPIF--
7<?php require_once('skipif.inc'); ?>
8--FILE--
9<?php
10namespace Foo;
11class Bar { public function get() {} }
12class Record implements \ArrayAccess {
13    public function offsetSet($offset, $value) { throw new \Exception; }
14    public function offsetGet($offset) { var_dump($offset); }
15    public function offsetExists($offset) { throw new \Exception; }
16    public function offsetUnset($offset) { throw new \Exception; }
17}
18class Baz {
19    public function run() {
20        $a = pow(1, 2);
21        $b = new Bar();
22        $c = new Bar();
23        $d = new Bar();
24        $id = $b->get('a', 'b', 'c');
25        $rec = new Record();
26        $id = $rec['a'];
27    }
28}
29(new Baz())->run();
30?>
31--EXPECT--
32string(1) "a"
33