xref: /PHP-7.4/Zend/tests/bug49908.phpt (revision 4b9ebd83)
1--TEST--
2Bug #49908 (throwing exception in __autoload 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 [internal function]: {closure}('Bar')
33#1 %s(%d): spl_autoload_call('Bar')
34#2 [internal function]: {closure}('Foo')
35#3 %s(%d): spl_autoload_call('Foo')
36#4 {main}
37  thrown in %s on line %d
38