helly Sat Jan 3 20:41:01 2009 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/reflection/tests 027.phpt
Modified files:
/php-src/ext/reflection php_reflection.c
/php-src/ext/reflection/tests
ReflectionMethod_getClosure_error.phpt
Log:
- MFH Minor corrections and a new test
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.45.2.49&r2=1.164.2.33.2.45.2.50&diff_format=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.49
php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.50
--- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.49 Sat Jan
3 20:04:22 2009
+++ php-src/ext/reflection/php_reflection.c Sat Jan 3 20:41:00 2009
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.49 2009/01/03 20:04:22 helly Exp
$ */
+/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.50 2009/01/03 20:41:00 helly Exp
$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -861,7 +861,7 @@
string_printf(str, "\n");
string_printf(str, "%s - Static Parameters [%d] {\n",
indent, count);
if (closure_this) {
- string_printf(str, "%s Parameter #%d [ %s
$this ]\n", indent, ++index, Z_OBJCE_P(closure_this)->name);
+ string_printf(str, "%s Parameter #%d [ %s
$this ]\n", indent, index++, Z_OBJCE_P(closure_this)->name);
}
if (static_variables) {
HashPosition pos;
@@ -869,7 +869,7 @@
char* key;
ulong num_index;
zend_hash_internal_pointer_reset_ex(static_variables, &pos);
- while (index++ < count) {
+ while (index < count) {
zend_hash_get_current_key_ex(static_variables, &key, &key_len, &num_index, 0,
&pos);
string_printf(str, "%s Parameter #%d
[ $%s ]\n", indent, index++, key);
zend_hash_move_forward_ex(static_variables, &pos);
@@ -1570,7 +1570,9 @@
GET_REFLECTION_OBJECT_PTR(fptr);
if (intern->obj) {
closure_this = zend_get_closure_this_ptr(intern->obj TSRMLS_CC);
- RETURN_ZVAL(closure_this, 1, 0);
+ if (closure_this) {
+ RETURN_ZVAL(closure_this, 1, 0);
+ }
}
}
/* }}} */
@@ -5378,7 +5380,7 @@
php_info_print_table_start();
php_info_print_table_header(2, "Reflection", "enabled");
- php_info_print_table_row(2, "Version", "$Revision: 1.164.2.33.2.45.2.49
$");
+ php_info_print_table_row(2, "Version", "$Revision: 1.164.2.33.2.45.2.50
$");
php_info_print_table_end();
} /* }}} */
@@ -5392,7 +5394,7 @@
NULL,
NULL,
PHP_MINFO(reflection),
- "$Revision: 1.164.2.33.2.45.2.49 $",
+ "$Revision: 1.164.2.33.2.45.2.50 $",
STANDARD_MODULE_PROPERTIES
}; /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt
diff -u
php-src/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt:1.1.2.1
php-src/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt:1.1.2.2
--- php-src/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt:1.1.2.1
Fri Aug 8 12:39:16 2008
+++ php-src/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt Sat Jan
3 20:41:01 2009
@@ -56,9 +56,13 @@
*** Testing ReflectionMethod::getClosure() : error conditions ***
-- Testing ReflectionMethod::getClosure() function with more than expected no.
of arguments --
-object(Closure)#%d (0) {
+object(Closure)#%d (1) {
+ ["this"]=>
+ NULL
}
-object(Closure)#%d (0) {
+object(Closure)#%d (1) {
+ ["this"]=>
+ NULL
}
Warning: ReflectionMethod::getClosure() expects exactly 1 parameter, 2 given
in %s on line %d
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/027.phpt?view=markup&rev=1.1
Index: php-src/ext/reflection/tests/027.phpt
+++ php-src/ext/reflection/tests/027.phpt
--TEST--
--FILE--
<?php
$global = 42;
$func = function($x, stdClass $y=NULL) use($global) {
static $static;
};
ReflectionFunction::Export($func);
$r = new ReflectionFunction($func);
var_dump(@get_class($r->getClosureThis()));
var_dump($r->getName());
var_dump($r->isClosure());
Class Test {
public $func;
function __construct(){
global $global;
$this->func = function($x, stdClass $y = NULL) use($global) {
static $static;
};
}
}
ReflectionMethod::export(new Test, "func");
$r = new ReflectionMethod(new Test, "func");
var_dump(get_class($r->getClosureThis()));
var_dump($r->getName());
var_dump($r->isClosure());
?>
===DONE===
--EXPECTF--
Closure [ <user> function {closure} ] {
@@ %s027.php 5 - 7
- Static Parameters [2] {
Parameter #0 [ $global ]
Parameter #1 [ $static ]
}
- Parameters [2] {
Parameter #0 [ <required> $x ]
Parameter #1 [ <optional> stdClass or NULL $y = NULL ]
}
}
NULL
unicode(9) "{closure}"
bool(true)
Closure [ <user> public method func ] {
@@ %s027.php 21 - 23
- Static Parameters [3] {
Parameter #0 [ Test $this ]
Parameter #1 [ $global ]
Parameter #2 [ $static ]
}
- Parameters [2] {
Parameter #0 [ <required> $x ]
Parameter #1 [ <optional> stdClass or NULL $y = NULL ]
}
}
unicode(4) "Test"
unicode(4) "func"
bool(true)
===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php