cvs: ZendEngine2 / zend_API.c php-src/ext/standard/tests/array array_map_object1.phpt
[email protected] ("Marcus Boerger")
| Newsgroups | php.zend-engine.cvs |
|---|---|
| Message-ID | <cvshelly1202330394@cvsserver> |
helly Wed Feb 6 20:39:54 2008 UTC
Modified files:
/php-src/ext/standard/tests/array array_map_object1.phpt
/ZendEngine2 zend_API.c
Log:
- Fix missing check and tests
helly-20080206203954.txt
(text/plain, 11.3 KB)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_map_object1.phpt?r1=1.2&r2=1.3&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.2 php-src/ext/standard/tests/array/array_map_object1.phpt:1.3
--- php-src/ext/standard/tests/array/array_map_object1.phpt:1.2 Mon Feb 4 15:22:08 2008
+++ php-src/ext/standard/tests/array/array_map_object1.phpt Wed Feb 6 20:39:54 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,11 +99,11 @@
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 @@
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
-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 @@
}
-- 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 @@
}
-- 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 @@
}
-- 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.458&r2=1.459&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.458 ZendEngine2/zend_API.c:1.459
--- ZendEngine2/zend_API.c:1.458 Tue Feb 5 19:06:59 2008
+++ ZendEngine2/zend_API.c Wed Feb 6 20:39:54 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.458 2008/02/05 19:06:59 helly Exp $ */
+/* $Id: zend_API.c,v 1.459 2008/02/06 20:39:54 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -2722,7 +2722,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_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) {