cvs: php-src /ext/spl php_spl.c /ext/spl/tests spl_autoload_004.phpt
| From: | Marcus Boerger | Date: | Wed, 10 Aug 2005 08:31:57 +0000 |
| Subject: | cvs: php-src /ext/spl php_spl.c /ext/spl/tests spl_autoload_004.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-33270@lists.php.net to get a copy of this message | ||
helly Wed Aug 10 04:31:57 2005 EDT
Added files:
/php-src/ext/spl/tests spl_autoload_004.phpt
Modified files:
/php-src/ext/spl php_spl.c
Log:
- Support sttaic class loader methods
http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.53&r2=1.54&ty=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.53 php-src/ext/spl/php_spl.c:1.54
--- php-src/ext/spl/php_spl.c:1.53 Tue Aug 9 17:11:42 2005
+++ php-src/ext/spl/php_spl.c Wed Aug 10 04:31:56 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_spl.c,v 1.53 2005/08/09 21:11:42 helly Exp $ */
+/* $Id: php_spl.c,v 1.54 2005/08/10 08:31:56 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -367,22 +367,18 @@
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|b", &zcallable,
&func_name_len, &do_throw) == FAILURE) {
return;
}
-#if MBO_0
if (!zend_is_callable_ex(zcallable, IS_CALLABLE_CHECK_IS_STATIC, &func_name,
&func_name_len, &func_ptr, NULL TSRMLS_CC)) {
if (do_throw) {
if (func_ptr) {
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Non static methods are not
supported yet");
} else {
- zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Passed array does not
specify a callable method or method");
+ zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Passed array does not
specify a callable sttaic method");
}
}
return;
}
lc_name = do_alloca(func_name_len + 1);
zend_str_tolower_copy(lc_name, func_name, func_name_len);
-#else
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Loader methods are not yet supported");
-#endif
} else if (ZEND_NUM_ARGS()) {
lc_name = do_alloca(func_name_len + 1);
zend_str_tolower_copy(lc_name, func_name, func_name_len);
@@ -493,7 +489,6 @@
zend_hash_internal_pointer_reset_ex(SPL_G(autoload_functions), &function_pos);
while(zend_hash_has_more_elements_ex(SPL_G(autoload_functions), &function_pos) == SUCCESS) {
zend_hash_get_current_data_ex(SPL_G(autoload_functions), (void **) &func_ptr_ptr,
&function_pos);
-#if MBO_0
if ((*func_ptr_ptr)->common.scope) {
zval *tmp;
MAKE_STD_ZVAL(tmp);
@@ -503,7 +498,6 @@
add_next_index_string(tmp, (*func_ptr_ptr)->common.function_name, 1);
add_next_index_zval(return_value, tmp);
} else
-#endif
add_next_index_string(return_value, (*func_ptr_ptr)->common.function_name, 1);
zend_hash_move_forward_ex(SPL_G(autoload_functions), &function_pos);
@@ -596,7 +590,7 @@
PHP_RINIT_FUNCTION(spl) /* {{{ */
{
- SPL_G(autoload_extensions) = estrdup(".inc,.php");
+ SPL_G(autoload_extensions) = estrndup(".inc,.php", sizeof(".inc,.php")-1);
return SUCCESS;
} /* }}} */
http://cvs.php.net/co.php/php-src/ext/spl/tests/spl_autoload_004.phpt?r=1.1&p=1
Index: php-src/ext/spl/tests/spl_autoload_004.phpt
+++ php-src/ext/spl/tests/spl_autoload_004.phpt
--TEST--
SPL: spl_autoload() with static methods
--INI--
include_path=.
--FILE--
<?php
class MyAutoLoader {
static function autoLoad($className) {
echo __METHOD__ . "($className)\n";
}
}
spl_autoload_register(array('MyAutoLoader', 'autoLoad'));
// and
$myAutoLoader = new MyAutoLoader();
spl_autoload_register(array($myAutoLoader, 'autoLoad'));
var_dump(spl_autoload_functions());
// check
var_dump(class_exists("TestClass", true));
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
array(1) {
[0]=>
array(2) {
[0]=>
string(12) "MyAutoLoader"
[1]=>
string(8) "autoLoad"
}
}
MyAutoLoader::autoLoad(TestClass)
bool(false)
===DONE===