1
0
mirror of https://github.com/php/php-src.git synced 2026-04-18 21:41:22 +02:00
Files
archived-php-src/ext/spl/tests/spl_autoload_002.phpt
Nikita Popov 5b59d4915c Cleanup SPL autoload implementation
Replace EG(autoload_func) with a C level zend_autoload hook.
This avoids having to do one indirection through PHP function
calls. The need for EG(autoload_func) was a leftover from the
__autoload() implementation.

Additionally, drop special-casing of spl_autoload(), and instead
register it just like any other autoloading function. This fixes
bug #71236 as a side-effect.

Finally, change spl_autoload_functions() to always return an array.
The distinction between false and an empty array no longer makes
sense here.

Closes GH-5696.
2020-06-10 09:38:47 +02:00

67 lines
1.0 KiB
PHP

--TEST--
SPL: spl_autoload_functions()
--FILE--
<?php
function SplAutoloadTest1($name) {}
function SplAutoloadTest2($name) {}
var_dump(spl_autoload_functions());
spl_autoload_register();
var_dump(spl_autoload_functions());
spl_autoload_register('SplAutoloadTest1');
spl_autoload_register('SplAutoloadTest2');
spl_autoload_register('SplAutoloadTest1');
var_dump(spl_autoload_functions());
spl_autoload_unregister('SplAutoloadTest1');
var_dump(spl_autoload_functions());
spl_autoload_unregister('spl_autoload_call');
var_dump(spl_autoload_functions());
spl_autoload_register();
var_dump(spl_autoload_functions());
spl_autoload_unregister('spl_autoload');
var_dump(spl_autoload_functions());
?>
--EXPECT--
array(0) {
}
array(1) {
[0]=>
string(12) "spl_autoload"
}
array(3) {
[0]=>
string(12) "spl_autoload"
[1]=>
string(16) "SplAutoloadTest1"
[2]=>
string(16) "SplAutoloadTest2"
}
array(2) {
[0]=>
string(12) "spl_autoload"
[1]=>
string(16) "SplAutoloadTest2"
}
array(0) {
}
array(1) {
[0]=>
string(12) "spl_autoload"
}
array(0) {
}