xref: /PHP-8.0/Zend/tests/bug49908.phpt (revision 5b59d491)
1--TEST--
2Bug #49908 (throwing exception in autoloader crashes when interface is not defined)
3--FILE--
4<?php
5
6spl_autoload_register(function ($className) {
7    var_dump($className);
8
9    if ($className == 'Foo') {
10        class Foo implements Bar {};
11    } else {
12        throw new Exception($className);
13    }
14});
15
16try {
17    new Foo();
18} catch (Exception $e) { }
19
20// We never reach here.
21var_dump(new Foo());
22
23?>
24--EXPECTF--
25string(3) "Foo"
26string(3) "Bar"
27string(3) "Foo"
28string(3) "Bar"
29
30Fatal error: Uncaught Exception: Bar in %s:%d
31Stack trace:
32#0 %s(%d): {closure}('Bar')
33#1 %s(%d): {closure}('Foo')
34#2 {main}
35  thrown in %s on line %d
36