bug41209.phpt 1013 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. Bug #41209 (Segmentation fault with ArrayAccess, set_error_handler and undefined var)
  3. --FILE--
  4. <?php
  5. class env
  6. {
  7. public function __construct()
  8. {
  9. set_error_handler(array(__CLASS__, 'errorHandler'));
  10. }
  11. public static function errorHandler($errno, $errstr, $errfile, $errline)
  12. {
  13. throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
  14. }
  15. }
  16. class cache implements ArrayAccess
  17. {
  18. private $container = array();
  19. public function offsetGet($id): mixed {}
  20. public function offsetSet($id, $value): void {}
  21. public function offsetUnset($id): void {}
  22. public function offsetExists($id): bool
  23. {
  24. return isset($this->containers[(string) $id]);
  25. }
  26. }
  27. $env = new env();
  28. $cache = new cache();
  29. var_dump(isset($cache[$id]));
  30. echo "Done\n";
  31. ?>
  32. --EXPECTF--
  33. Fatal error: Uncaught ErrorException: Undefined variable $id in %s:%d
  34. Stack trace:
  35. #0 %s(%d): env::errorHandler(2, 'Undefined varia...', '%s', %d)
  36. #1 {main}
  37. thrown in %s on line %d