mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
- Let spl_autoload_extensions() always return what's registered
This commit is contained in:
parent
e628f2d9fa
commit
30ee47c1d8
@ -242,21 +242,25 @@ PHP_FUNCTION(spl_autoload)
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
/* {{{ void spl_autoload_extensions(string file_extensions])
|
||||
Register default file extensions for spl_autoload */
|
||||
/* {{{ void string spl_autoload_extensions([string file_extensions])
|
||||
Register and return default file extensions for spl_autoload */
|
||||
PHP_FUNCTION(spl_autoload_extensions)
|
||||
{
|
||||
char *file_exts;
|
||||
int file_exts_len;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file_exts, &file_exts_len) == FAILURE) {
|
||||
return;
|
||||
if (ZEND_NUM_ARGS() > 0) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file_exts, &file_exts_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SPL_G(autoload_extensions)) {
|
||||
efree(SPL_G(autoload_extensions));
|
||||
}
|
||||
SPL_G(autoload_extensions) = estrdup(file_exts);
|
||||
}
|
||||
|
||||
if (SPL_G(autoload_extensions)) {
|
||||
efree(SPL_G(autoload_extensions));
|
||||
}
|
||||
SPL_G(autoload_extensions) = estrdup(file_exts);
|
||||
RETURN_STRING(SPL_G(autoload_extensions), 1);
|
||||
} /* }}} */
|
||||
|
||||
/* {{{ void spl_autoload_call(string class_name)
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
SPL spl_autoload() and friends
|
||||
SPL: spl_autoload() and friends
|
||||
--INI--
|
||||
include_path=.
|
||||
--FILE--
|
||||
@ -7,6 +7,8 @@ include_path=.
|
||||
|
||||
echo "===EMPTY===\n";
|
||||
|
||||
var_dump(spl_autoload_extensions());
|
||||
|
||||
try
|
||||
{
|
||||
spl_autoload("TestClass");
|
||||
@ -57,7 +59,7 @@ spl_autoload_register();
|
||||
|
||||
try
|
||||
{
|
||||
spl_autoload_extensions(".inc");
|
||||
var_dump(spl_autoload_extensions(".inc"));
|
||||
var_dump(class_exists("TestClass", true));
|
||||
}
|
||||
catch(Exception $e)
|
||||
@ -102,6 +104,7 @@ catch(Exception $e)
|
||||
<?php exit(0); ?>
|
||||
--EXPECTF--
|
||||
===EMPTY===
|
||||
string(13) ".inc,.inc.php"
|
||||
%stestclass.inc
|
||||
Exception: Class TestClass could not be loaded
|
||||
===()===
|
||||
@ -116,6 +119,7 @@ Exception: Class TestClass could not be loaded
|
||||
Exception: Class TestClass could not be loaded
|
||||
Exception: Class TestClass could not be loaded
|
||||
===SPL_AUTOLOAD()===
|
||||
string(4) ".inc"
|
||||
Exception: Class TestClass could not be loaded
|
||||
===REGISTER===
|
||||
TestFunc1(TestClass)
|
||||
|
Loading…
Reference in New Issue
Block a user