no-switch-dtor-throw.phpt 695 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. Cannot resume fiber within destructor
  3. --FILE--
  4. <?php
  5. $fiber = new Fiber(function () {
  6. Fiber::suspend();
  7. });
  8. $fiber->start();
  9. return new class ($fiber) {
  10. private $fiber;
  11. public function __construct(Fiber $fiber) {
  12. $this->fiber = $fiber;
  13. }
  14. public function __destruct() {
  15. $this->fiber->throw(new Error());
  16. }
  17. };
  18. ?>
  19. --EXPECTF--
  20. Fatal error: Uncaught FiberError: Cannot switch fibers in current execution context in %sno-switch-dtor-throw.php:%d
  21. Stack trace:
  22. #0 %sno-switch-dtor-throw.php(%d): Fiber->throw(Object(Error))
  23. #1 %sno-switch-dtor-throw.php(%d): class@anonymous->__destruct()
  24. #2 {main}
  25. thrown in %sno-switch-dtor-throw.php on line %d