mirror of
https://github.com/php/php-src.git
synced 2026-04-12 18:43:37 +02:00
The "callable name" may be the same for multiple distinct callables. The code already worked around this for the case of instance methods, but there are other cases in which callable names clash, such as the use of self:: reported in the referenced bug. Rather than trying to generate a unique name for callables, compare the content of the alfi structures. This is less efficient if there are many autoload functions, but autoload *registration* does not need to be particularly efficient. As a side-effect, this no longer permits unregistering non-callables.
42 lines
665 B
PHP
42 lines
665 B
PHP
--TEST--
|
|
Bug #65006: spl_autoload_register fails with multiple callables using self, same method
|
|
--FILE--
|
|
<?php
|
|
|
|
class first {
|
|
public static function init() {
|
|
spl_autoload_register(array('self','load'));
|
|
}
|
|
public static function load($class) {}
|
|
}
|
|
|
|
class second {
|
|
public static function init() {
|
|
spl_autoload_register(array('self','load'));
|
|
}
|
|
public static function load($class){}
|
|
}
|
|
|
|
first::init();
|
|
second::init();
|
|
var_dump(spl_autoload_functions());
|
|
|
|
?>
|
|
--EXPECT--
|
|
array(2) {
|
|
[0]=>
|
|
array(2) {
|
|
[0]=>
|
|
string(5) "first"
|
|
[1]=>
|
|
string(4) "load"
|
|
}
|
|
[1]=>
|
|
array(2) {
|
|
[0]=>
|
|
string(6) "second"
|
|
[1]=>
|
|
string(4) "load"
|
|
}
|
|
}
|