bug54367.phpt 545 B

123456789101112131415161718192021222324
  1. --TEST--
  2. Bug #54367 (Use of closure causes problem in ArrayAccess)
  3. --FILE--
  4. <?php
  5. class MyObjet implements ArrayAccess
  6. {
  7. public function offsetSet($offset, $value): void { }
  8. public function offsetExists($offset): bool { }
  9. public function offsetUnset($offset): void { }
  10. public function offsetGet($offset): mixed
  11. {
  12. return function ($var) use ($offset) { // here is the problem
  13. var_dump($offset, $var);
  14. };
  15. }
  16. }
  17. $a = new MyObjet();
  18. echo $a['p']('foo');
  19. ?>
  20. --EXPECT--
  21. string(1) "p"
  22. string(3) "foo"