From: Marcus Boerger Date: Wed, 6 Feb 2008 20:39:54 +0000 (+0000) Subject: - Fix missing check and tests X-Git-Tag: RELEASE_2_0_0a1~593 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ad89748c3acd0196fbec88b294d9a57756add85;p=php - Fix missing check and tests --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 305444e1f9..2e76986bb5 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2722,7 +2722,9 @@ static int zend_is_callable_check_func(int check_flags, zval ***zobj_ptr_ptr, ze /* This is a compound name. * Try to fetch class and then find static method. */ zend_class_entry *last_scope = EG(scope); - EG(scope) = ce_org; + if (ce_org) { + EG(scope) = ce_org; + } *ce_ptr = zend_u_fetch_class(Z_TYPE_P(callable), Z_UNIVAL_P(callable), clen, ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_SILENT TSRMLS_CC); EG(scope) = last_scope; if (!*ce_ptr) { diff --git a/ext/standard/tests/array/array_map_object1.phpt b/ext/standard/tests/array/array_map_object1.phpt index b508e9d6ba..64b91fbec9 100644 --- a/ext/standard/tests/array/array_map_object1.phpt +++ b/ext/standard/tests/array/array_map_object1.phpt @@ -26,7 +26,11 @@ class SimpleClass return $n * $n; } } -var_dump( array_map(array('SimpleClass', 'square'), array(1, 2)) ); +function test($cb, $args) { + echo join('::', $cb) . "\n"; + var_dump(array_map($cb, $args)); +} +test(array('SimpleClass', 'square'), array(1, 2)); echo "\n-- simple class with private variable and method --\n"; class SimpleClassPri @@ -36,7 +40,7 @@ class SimpleClassPri return $var + $n; } } -var_dump( array_map(array('SimpleClassPri', 'add'), array(1)) ); +test(array('SimpleClassPri', 'add'), array(1)); echo "\n-- simple class with protected variable and method --\n"; class SimpleClassPro @@ -46,15 +50,15 @@ class SimpleClassPro return $var1 * $n; } } -var_dump( array_map(array('SimpleClassPro', 'mul'), array(2)) ); +test(array('SimpleClassPro', 'mul'), array(2)); -echo "\n-- class without members --"; +echo "\n-- class without members --\n"; class EmptyClass { } -var_dump( array_map(array('EmptyClass'), array(1, 2)) ); +test(array('EmptyClass'), array(1, 2)); -echo "\n-- abstract class --"; +echo "\n-- abstract class --\n"; abstract class AbstractClass { protected $var2 = 5; @@ -69,9 +73,9 @@ class ChildClass extends AbstractClass echo "defined in child"; } } -var_dump( array_map(array('ChildClass', 'emptyFunction'), array(1, 2)) ); +test(array('ChildClass', 'emptyFunction'), array(1, 2)); -echo "\n-- class with final method --"; +echo "\n-- class with final method --\n"; class FinalClass { private $var4; @@ -79,7 +83,7 @@ class FinalClass echo "This function can't be overloaded"; } } -var_dump( array_map(array('FinalClass', 'finalMethod'), array(1, 2)) ); +test(array('FinalClass', 'finalMethod'), array(1, 2)); echo "\n-- class with static members --\n"; class StaticClass @@ -95,11 +99,11 @@ class StaticClass return array($n); } } -var_dump( array_map(array('StaticClass', 'square'), array(1, 2)) ); -var_dump( array_map(array('StaticClass', 'cube'), array(2)) ); -var_dump( array_map(array('StaticClass', 'retVal'), array(3, 4)) ); +test(array('StaticClass', 'square'), array(1, 2)); +test(array('StaticClass', 'cube'), array(2)); +test(array('StaticClass', 'retVal'), array(3, 4)); -echo "-- class implementing an interface --\n"; +echo "\n-- class implementing an interface --\n"; interface myInterface { public function toImplement(); @@ -113,19 +117,21 @@ class InterClass implements myInterface return 1; } } -var_dump( array_map(array('InterClass', 'square'), array(1, 2))); +test(array('InterClass', 'square'), array(1, 2)); -echo "Done"; ?> +===DONE=== + --EXPECTF-- *** Testing array_map() : object functionality *** -- simple class with public variable and method -- +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 %s on line %d +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 %s 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 %s 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) @@ -134,102 +140,31 @@ array(2) { } -- simple class with private variable and method -- +SimpleClassPri::add -Warning: array_map() expects parameter 1 to be a valid callback, cannot access private method SimpleClassPri::add() in %s on line %d +Warning: array_map() expects parameter 1 to be a valid callback, cannot access private method SimpleClassPri::add() in %sarray_map_object1.php on line %d NULL -- simple class with protected variable and method -- +SimpleClassPro::mul -Warning: array_map() expects parameter 1 to be a valid callback, cannot access protected method SimpleClassPro::mul() in %s on line %d +Warning: array_map() expects parameter 1 to be a valid callback, cannot access protected method SimpleClassPro::mul() in %sarray_map_object1.php on line %d NULL -- class without members -- -Warning: array_map() expects parameter 1 to be a valid callback, array must have exactly two members in %s on line %d -NULL - --- abstract class -- -Strict Standards: array_map() expects parameter 1 to be a valid callback, non-static method ChildClass::emptyFunction() should not be called statically in %s on line %d - -Strict Standards: Non-static method ChildClass::emptyFunction() should not be called statically in %s on line %d -defined in child -Strict Standards: Non-static method ChildClass::emptyFunction() should not be called statically in %s on line %d -defined in childarray(2) { - [0]=> - NULL - [1]=> - NULL -} - --- class with final method -- -Strict Standards: array_map() expects parameter 1 to be a valid callback, non-static method FinalClass::finalMethod() should not be called statically in %s on line %d - -Strict Standards: Non-static method FinalClass::finalMethod() should not be called statically in %s on line %d -This function can't be overloaded -Strict Standards: Non-static method FinalClass::finalMethod() should not be called statically in %s on line %d -This function can't be overloadedarray(2) { - [0]=> - NULL - [1]=> - NULL -} - --- class with static members -- -array(2) { - [0]=> - int(1) - [1]=> - int(4) -} - -Warning: array_map() expects parameter 1 to be a valid callback, cannot access private method StaticClass::cube() in %s on line %d -NULL +EmptyClass -Warning: array_map() expects parameter 1 to be a valid callback, cannot access protected method StaticClass::retVal() in %s on line %d -NULL --- class implementing an interface -- -array(2) { - [0]=> - int(1) - [1]=> - int(4) -} -Done ---UEXPECTF-- -*** Testing array_map() : object functionality *** --- simple class with public variable and method -- - -Strict Standards: array_map() expects parameter 1 to be a valid callback, non-static method SimpleClass::square() should not be called statically in %s on line %d - -Strict Standards: Non-static method SimpleClass::square() should not be called statically in %s on line %d - -Strict Standards: Non-static method SimpleClass::square() should not be called statically in %s on line %d -array(2) { - [0]=> - int(1) - [1]=> - int(4) -} - --- simple class with private variable and method -- - -Warning: array_map() expects parameter 1 to be a valid callback, cannot access private method SimpleClassPri::add() in %s on line %d -NULL - --- simple class with protected variable and method -- - -Warning: array_map() expects parameter 1 to be a valid callback, cannot access protected method SimpleClassPro::mul() in %s on line %d -NULL - --- class without members -- -Warning: array_map() expects parameter 1 to be a valid callback, array must have exactly two members in %s on line %d +Warning: array_map() expects parameter 1 to be a valid callback, array must have exactly two members in %sarray_map_object1.php on line %d NULL -- abstract class -- -Strict Standards: array_map() expects parameter 1 to be a valid callback, non-static method ChildClass::emptyFunction() should not be called statically in %s on line %d +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 %s 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 %s 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 childarray(2) { [0]=> NULL @@ -238,11 +173,13 @@ defined in childarray(2) { } -- class with final method -- -Strict Standards: array_map() expects parameter 1 to be a valid callback, non-static method FinalClass::finalMethod() should not be called statically in %s on line %d +FinalClass::finalMethod -Strict Standards: Non-static method FinalClass::finalMethod() should not be called statically in %s on line %d +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 %s 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 overloadedarray(2) { [0]=> NULL @@ -251,23 +188,28 @@ This function can't be overloadedarray(2) { } -- class with static members -- +StaticClass::square array(2) { [0]=> int(1) [1]=> int(4) } +StaticClass::cube -Warning: array_map() expects parameter 1 to be a valid callback, cannot access private method StaticClass::cube() in %s on line %d +Warning: array_map() expects parameter 1 to be a valid callback, cannot access private method StaticClass::cube() in %sarray_map_object1.php on line %d NULL +StaticClass::retVal -Warning: array_map() expects parameter 1 to be a valid callback, cannot access protected method StaticClass::retVal() in %s on line %d +Warning: array_map() expects parameter 1 to be a valid callback, cannot access protected method StaticClass::retVal() in %sarray_map_object1.php on line %d NULL + -- class implementing an interface -- +InterClass::square array(2) { [0]=> int(1) [1]=> int(4) } -Done +===DONE===