spl_autoload_012.phpt 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. SPL: spl_autoload() capturing multiple Exceptions in __autoload
  3. --FILE--
  4. <?php
  5. function autoload_first($name)
  6. {
  7. echo __METHOD__ . "\n";
  8. throw new Exception('first');
  9. }
  10. function autoload_second($name)
  11. {
  12. echo __METHOD__ . "\n";
  13. throw new Exception('second');
  14. }
  15. spl_autoload_register('autoload_first');
  16. spl_autoload_register('autoload_second');
  17. try {
  18. class_exists('ThisClassDoesNotExist');
  19. } catch(Exception $e) {
  20. do {
  21. echo $e->getMessage()."\n";
  22. } while($e = $e->getPrevious());
  23. }
  24. try {
  25. new ThisClassDoesNotExist;
  26. } catch(Exception $e) {
  27. do {
  28. echo $e->getMessage()."\n";
  29. } while($e = $e->getPrevious());
  30. }
  31. class_exists('ThisClassDoesNotExist');
  32. ?>
  33. ===DONE===
  34. --EXPECTF--
  35. autoload_first
  36. first
  37. autoload_first
  38. first
  39. autoload_first
  40. Fatal error: Uncaught Exception: first in %sspl_autoload_012.php:%d
  41. Stack trace:
  42. #0 [internal function]: autoload_first('ThisClassDoesNo...')
  43. #1 %sspl_autoload_012.php(%d): class_exists('ThisClassDoesNo...')
  44. #2 {main}
  45. thrown in %s on line %d