exception_rethrown.phpt 847 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Test rethrowing in custom exception handler
  3. --FILE--
  4. <?php
  5. namespace Symfony\Component\ErrorHandler;
  6. $vendor = __DIR__;
  7. while (!file_exists($vendor.'/vendor')) {
  8. $vendor = \dirname($vendor);
  9. }
  10. require $vendor.'/vendor/autoload.php';
  11. if (true) {
  12. class TestLogger extends \Psr\Log\AbstractLogger
  13. {
  14. public function log($level, $message, array $context = []): void
  15. {
  16. if (0 !== strpos($message, 'Deprecated: ')) {
  17. echo 'LOG: ', $message, "\n";
  18. }
  19. }
  20. }
  21. }
  22. $_SERVER['NO_COLOR'] = '1';
  23. set_exception_handler(function ($e) { echo "EHLO\n"; throw $e; });
  24. ErrorHandler::register()->setDefaultLogger(new TestLogger());
  25. throw new \Exception('foo');
  26. ?>
  27. --EXPECTF--
  28. LOG: Uncaught Exception: foo
  29. EHLO
  30. Exception {%S
  31. #message: "foo"
  32. #code: 0
  33. #file: "%s"
  34. #line: 27
  35. }