xref: /PHP-7.3/ext/spl/tests/bug71202.phpt (revision e21cb2da)
1--TEST--
2Bug #71202 (Autoload function registered by another not activated immediately)
3--FILE--
4<?php
5
6function inner_autoload ($name){
7	if ($name == 'A') {
8		class A {
9			function __construct(){
10				echo "okey, ";
11			}
12		}
13	} else {
14		class B {
15			function __construct() {
16				die("error");
17			}
18		}
19	}
20}
21
22spl_autoload_register(function ($name) {
23	if ($name == 'A') {
24		spl_autoload_register("inner_autoload");
25	} else {
26		spl_autoload_unregister("inner_autoload");
27	}
28});
29
30$c = new A();
31try {
32	$c = new B();
33} catch (Error $e) {
34	echo "done";
35}
36?>
37--EXPECT--
38okey, done
39