no-switch-dtor-resume.phpt 679 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->resume(1);
  16. }
  17. };
  18. ?>
  19. --EXPECTF--
  20. Fatal error: Uncaught FiberError: Cannot switch fibers in current execution context in %sno-switch-dtor-resume.php:%d
  21. Stack trace:
  22. #0 %sno-switch-dtor-resume.php(%d): Fiber->resume(1)
  23. #1 %sno-switch-dtor-resume.php(%d): class@anonymous->__destruct()
  24. #2 {main}
  25. thrown in %sno-switch-dtor-resume.php on line %d