unfinished-fiber-with-throw-in-finally.phpt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. Test unfinished fiber with suspend in finally
  3. --FILE--
  4. <?php
  5. $fiber = new Fiber(function (): void {
  6. try {
  7. try {
  8. try {
  9. echo "fiber\n";
  10. echo Fiber::suspend();
  11. echo "after await\n";
  12. } catch (Throwable $exception) {
  13. echo "inner exit exception caught!\n";
  14. }
  15. } catch (Throwable $exception) {
  16. echo "exit exception caught!\n";
  17. } finally {
  18. echo "inner finally\n";
  19. throw new \Exception("finally exception");
  20. }
  21. } catch (Exception $exception) {
  22. echo $exception->getMessage(), "\n";
  23. } finally {
  24. echo "outer finally\n";
  25. }
  26. try {
  27. echo Fiber::suspend();
  28. } catch (FiberError $exception) {
  29. echo $exception->getMessage(), "\n";
  30. }
  31. });
  32. $fiber->start();
  33. unset($fiber); // Destroy fiber object, executing finally block.
  34. echo "done\n";
  35. ?>
  36. --EXPECT--
  37. fiber
  38. inner finally
  39. finally exception
  40. outer finally
  41. Cannot suspend in a force-closed fiber
  42. done