Fixed is_callable/call_user_func mess that had done different things for very similar arguments e.g. array("A","B") and "A::B"

This commit is contained in:
Dmitry Stogov 2008-07-26 13:14:04 +00:00
parent 77baec3f6d
commit af05ce0af6
17 changed files with 223 additions and 417 deletions

View file

@ -1258,7 +1258,7 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
params[0] = &reflector_ptr;
params[1] = &output_ptr;
ZVAL_STRINGL(&fname, "export", sizeof("export") - 1, 0);
ZVAL_STRINGL(&fname, "reflection::export", sizeof("reflection::export") - 1, 0);
fci.function_table = &reflection_ptr->function_table;
fci.function_name = &fname;
fci.object_pp = NULL;

View file

@ -451,7 +451,7 @@ PHP_FUNCTION(spl_autoload_register)
}
}
if (!zend_is_callable_ex(zcallable, IS_CALLABLE_STRICT, &func_name, &func_name_len, &fcc, &error TSRMLS_CC)) {
if (!zend_is_callable_ex(zcallable, NULL, IS_CALLABLE_STRICT, &func_name, &func_name_len, &fcc, &error TSRMLS_CC)) {
alfi.ce = fcc.calling_scope;
alfi.func_ptr = fcc.function_handler;
obj_ptr = fcc.object_pp;
@ -573,7 +573,7 @@ PHP_FUNCTION(spl_autoload_unregister)
return;
}
if (!zend_is_callable_ex(zcallable, IS_CALLABLE_CHECK_SYNTAX_ONLY, &func_name, &func_name_len, &fcc, &error TSRMLS_CC)) {
if (!zend_is_callable_ex(zcallable, NULL, IS_CALLABLE_CHECK_SYNTAX_ONLY, &func_name, &func_name_len, &fcc, &error TSRMLS_CC)) {
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Unable to unregister invalid function (%s)", error);
if (error) {
efree(error);

View file

@ -57,7 +57,7 @@ foreach($funcs as $idx => $func)
<?php exit(0); ?>
--EXPECTF--
string(22) "MyAutoLoader::notExist"
Function 'MyAutoLoader::notExist' not found (class 'MyAutoLoader' does not have a method 'notexist')
Function 'MyAutoLoader::notExist' not found (class 'MyAutoLoader' does not have a method 'notExist')
string(22) "MyAutoLoader::noAccess"
Function 'MyAutoLoader::noAccess' not callable (cannot access protected method MyAutoLoader::noAccess())
@ -74,7 +74,7 @@ array(2) {
[1]=>
string(8) "notExist"
}
Passed array does not specify an existing static method (class 'MyAutoLoader' does not have a method 'notexist')
Passed array does not specify an existing static method (class 'MyAutoLoader' does not have a method 'notExist')
array(2) {
[0]=>
@ -107,7 +107,7 @@ array(2) {
[1]=>
string(8) "notExist"
}
Passed array does not specify an existing method (class 'MyAutoLoader' does not have a method 'notexist')
Passed array does not specify an existing method (class 'MyAutoLoader' does not have a method 'notExist')
array(2) {
[0]=>

View file

@ -70,7 +70,7 @@ class ChildClass extends AbstractClass
{
private $var3;
public function emptyFunction() {
echo "defined in child";
echo "defined in child\n";
}
}
test(array('ChildClass', 'emptyFunction'), array(1, 2));
@ -80,7 +80,7 @@ class FinalClass
{
private $var4;
final function finalMethod() {
echo "This function can't be overloaded";
echo "This function can't be overloaded\n";
}
}
test(array('FinalClass', 'finalMethod'), array(1, 2));
@ -128,10 +128,6 @@ test(array('InterClass', 'square'), array(1, 2));
SimpleClass::square
Strict Standards: array_map() expects parameter 1 to be a valid callback, non-static method SimpleClass::square() should not be called statically in %sarray_map_object1.php on line %d
Strict Standards: Non-static method SimpleClass::square() should not be called statically in %sarray_map_object1.php on line %d
Strict Standards: Non-static method SimpleClass::square() should not be called statically in %sarray_map_object1.php on line %d
array(2) {
[0]=>
int(1)
@ -161,11 +157,9 @@ NULL
ChildClass::emptyFunction
Strict Standards: array_map() expects parameter 1 to be a valid callback, non-static method ChildClass::emptyFunction() should not be called statically in %sarray_map_object1.php on line %d
Strict Standards: Non-static method ChildClass::emptyFunction() should not be called statically in %sarray_map_object1.php on line %d
defined in child
Strict Standards: Non-static method ChildClass::emptyFunction() should not be called statically in %sarray_map_object1.php on line %d
defined in childarray(2) {
defined in child
array(2) {
[0]=>
NULL
[1]=>
@ -176,11 +170,9 @@ defined in childarray(2) {
FinalClass::finalMethod
Strict Standards: array_map() expects parameter 1 to be a valid callback, non-static method FinalClass::finalMethod() should not be called statically in %sarray_map_object1.php on line %d
Strict Standards: Non-static method FinalClass::finalMethod() should not be called statically in %sarray_map_object1.php on line %d
This function can't be overloaded
Strict Standards: Non-static method FinalClass::finalMethod() should not be called statically in %sarray_map_object1.php on line %d
This function can't be overloadedarray(2) {
This function can't be overloaded
array(2) {
[0]=>
NULL
[1]=>

View file

@ -74,7 +74,7 @@ array(3) {
}
-- accessing child method from parent class --
Warning: array_map() expects parameter 1 to be a valid callback, class 'ParentClass' does not have a method 'staticchild' in %s on line %d
Warning: array_map() expects parameter 1 to be a valid callback, class 'ParentClass' does not have a method 'staticChild' in %s on line %d
NULL
-- accessing parent method using child class object --
array(3) {
@ -87,6 +87,6 @@ array(3) {
}
-- accessing child method using parent class object --
Warning: array_map() expects parameter 1 to be a valid callback, class 'ParentClass' does not have a method 'staticchild' in %s on line %d
Warning: array_map() expects parameter 1 to be a valid callback, class 'ParentClass' does not have a method 'staticChild' in %s on line %d
NULL
Done

View file

@ -77,16 +77,8 @@ new Derived_6('6');
--EXPECTF--
Base::__construct(1)
Base::__construct(2)
Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method Base::__construct() cannot be called statically, assuming $this from compatible context Derived_%d in %s on line %d
Base::__construct(3)
Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method Base::__construct() cannot be called statically, assuming $this from compatible context Derived_%d in %s on line %d
Base::__construct(4)
Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method Base::__construct() cannot be called statically, assuming $this from compatible context Derived_%d in %s on line %d
Base::__construct(5)
Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method Base::__construct() cannot be called statically, assuming $this from compatible context Derived_%d in %s on line %d
Base::__construct(6)
===DONE===

View file

@ -97,12 +97,8 @@ B|who2
A
===FOREIGN===
parent|who
Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method O::who() should not be called statically, assuming $this from compatible context P in %s on line %d
O
P|parent::who
Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method O::who() should not be called statically, assuming $this from compatible context P in %s on line %d
O
$this|O::who
O