bug77275.phpt 869 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. Bug #77275: OPcache optimization problem for ArrayAccess->offsetGet(string)
  3. --INI--
  4. opcache.enable_cli=1
  5. opcache.optimization_level=-1
  6. --EXTENSIONS--
  7. opcache
  8. --FILE--
  9. <?php
  10. namespace Foo;
  11. class Bar { public function get() {} }
  12. class Record implements \ArrayAccess {
  13. public function offsetSet($offset, $value): void { throw new \Exception; }
  14. public function offsetGet($offset): mixed { var_dump($offset); return null; }
  15. public function offsetExists($offset): bool { throw new \Exception; }
  16. public function offsetUnset($offset): void { throw new \Exception; }
  17. }
  18. class 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--
  32. string(1) "a"