FunctionSetRejectionHandlerThatThrowsShouldTerminateProgramForUnhandled.phpt 729 B

1234567891011121314151617181920212223242526
  1. --TEST--
  2. The callback given to set_rejection_handler() should not throw an exception or the program should terminate for unhandled rejection
  3. --INI--
  4. # suppress legacy PHPUnit 7 warning for Xdebug 3
  5. xdebug.default_enable=
  6. --FILE--
  7. <?php
  8. use function React\Promise\reject;
  9. use function React\Promise\set_rejection_handler;
  10. require __DIR__ . '/../vendor/autoload.php';
  11. set_rejection_handler(function (Throwable $e): void {
  12. throw new \UnexpectedValueException('This function should never throw');
  13. });
  14. reject(new RuntimeException('foo'));
  15. echo 'NEVER';
  16. ?>
  17. --EXPECTF--
  18. Fatal error: Uncaught UnexpectedValueException from unhandled promise rejection handler: This function should never throw in %s:%d
  19. Stack trace:
  20. #0 %A{main}