no-switch-dtor-suspend.phpt 599 B

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