From: Marcus Boerger Date: Wed, 2 Mar 2005 20:59:06 +0000 (+0000) Subject: - Let spl_autoload_extensions() always return what's registered X-Git-Tag: RELEASE_0_3~97 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30ee47c1d87411cd99edc171b6052c526d3a1b4a;p=php - Let spl_autoload_extensions() always return what's registered --- diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index e09f98ebb2..884ac30e09 100755 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -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) diff --git a/ext/spl/tests/spl_autoload_001.phpt b/ext/spl/tests/spl_autoload_001.phpt index 58b9339f81..5185a8ee1c 100755 --- a/ext/spl/tests/spl_autoload_001.phpt +++ b/ext/spl/tests/spl_autoload_001.phpt @@ -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) --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)