cvs: ZendEngine2(PHP_5_3) / zend_API.c php-src/ext/standard/tests/array array_map_object1.phpt
[email protected] ("Marcus Boerger")
| Newsgroups | php.zend-engine.cvs |
|---|---|
| Message-ID | <cvshelly1202330419@cvsserver> |
helly Wed Feb 6 20:40:19 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/array array_map_object1.phpt
/ZendEngine2 zend_API.c
Log:
- MFH Fix missing check and tests
helly-20080206204019.txt
(text/plain, 8.4 KB)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_map_object1.phpt?r1=1.1.2.3&r2=1.1.2.4&diff_format=u
Index: php-src/ext/standard/tests/array/array_map_object1.phpt
diff -u php-src/ext/standard/tests/array/array_map_object1.phpt:1.1.2.3 php-src/ext/standard/tests/array/array_map_object1.phpt:1.1.2.4
--- php-src/ext/standard/tests/array/array_map_object1.phpt:1.1.2.3 Sat Feb 2 01:51:17 2008
+++ php-src/ext/standard/tests/array/array_map_object1.phpt Wed Feb 6 20:40:19 2008
@@ -26,7 +26,11 @@
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 @@
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 @@
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 @@
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 @@
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,9 +99,9 @@
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";
interface myInterface
@@ -113,63 +117,98 @@
return 1;
}
}
-var_dump( array_map(array('InterClass', 'square'), array(1, 2)));
+test(array('InterClass', 'square'), array(1, 2));
-echo "Done";
?>
+===DONE===
+<?php exit(0); ?>
--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
-Warning: array_map() expects parameter 2 to be a valid callback, second array member is not a valid method in %s on line %d
-NULL
+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)
+ [1]=>
+ int(4)
+}
-- 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
+EmptyClass
+
+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
-Warning: array_map() expects parameter 2 to be a valid callback, second array member is not a valid method in %s on line %d
-NULL
+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) {
+ [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
+FinalClass::finalMethod
-Warning: array_map() expects parameter 2 to be a valid callback, second array member is not a valid method in %s on line %d
-NULL
+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) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+}
-- 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===
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.296.2.27.2.34.2.26&r2=1.296.2.27.2.34.2.27&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.296.2.27.2.34.2.26 ZendEngine2/zend_API.c:1.296.2.27.2.34.2.27
--- ZendEngine2/zend_API.c:1.296.2.27.2.34.2.26 Tue Feb 5 19:08:24 2008
+++ ZendEngine2/zend_API.c Wed Feb 6 20:40:19 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.296.2.27.2.34.2.26 2008/02/05 19:08:24 helly Exp $ */
+/* $Id: zend_API.c,v 1.296.2.27.2.34.2.27 2008/02/06 20:40:19 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -2360,7 +2360,9 @@
/* 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_fetch_class(Z_STRVAL_P(callable), clen, ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_SILENT TSRMLS_CC);
EG(scope) = last_scope;
if (!*ce_ptr) {