xref: /PHP-8.4/ext/spl/tests/bug40091.phpt (revision f8d79582)
1--TEST--
2Bug #40091 (issue with spl_autoload_register() and 2 instances of the same class)
3--FILE--
4<?php
5class MyAutoloader {
6    function __construct($directory_to_use) {}
7    function autoload($class_name) {
8        // code to autoload based on directory
9    }
10}
11
12$autloader1 = new MyAutoloader('dir1');
13spl_autoload_register(array($autloader1, 'autoload'));
14
15$autloader2 = new MyAutoloader('dir2');
16spl_autoload_register(array($autloader2, 'autoload'));
17
18print_r(spl_autoload_functions());
19?>
20--EXPECT--
21Array
22(
23    [0] => Array
24        (
25            [0] => MyAutoloader Object
26                (
27                )
28
29            [1] => autoload
30        )
31
32    [1] => Array
33        (
34            [0] => MyAutoloader Object
35                (
36                )
37
38            [1] => autoload
39        )
40
41)
42