bug31102.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. Bug #31102 (Exception not handled when thrown inside autoloader)
  3. --FILE--
  4. <?php
  5. $test = 0;
  6. spl_autoload_register(function ($class) {
  7. global $test;
  8. echo __METHOD__ . "($class,$test)\n";
  9. switch($test)
  10. {
  11. case 1:
  12. eval("class $class { function __construct(){throw new Exception('$class::__construct');}}");
  13. return;
  14. case 2:
  15. eval("class $class { function __construct(){throw new Exception('$class::__construct');}}");
  16. throw new Exception(__METHOD__);
  17. return;
  18. case 3:
  19. return;
  20. }
  21. });
  22. while($test++ < 5)
  23. {
  24. try
  25. {
  26. eval("\$bug = new Test$test();");
  27. }
  28. catch (Exception $e)
  29. {
  30. echo "Caught: " . $e->getMessage() . "\n";
  31. }
  32. }
  33. ?>
  34. ===DONE===
  35. --EXPECTF--
  36. {closure}(Test1,1)
  37. Caught: Test1::__construct
  38. {closure}(Test2,2)
  39. Caught: {closure}
  40. {closure}(Test3,3)
  41. Fatal error: Uncaught Error: Class "Test3" not found in %s:%d
  42. Stack trace:
  43. #0 %s(%d): eval()
  44. #1 {main}
  45. thrown in %sbug31102.php(%d) : eval()'d code on line 1