helly Sat Jan 3 20:40:22 2009 UTC Added files: /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: - Minor corrections and a new test http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.336&r2=1.337&diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.336 php-src/ext/reflection/php_reflection.c:1.337 --- php-src/ext/reflection/php_reflection.c:1.336 Sat Jan 3 20:03:45 2009 +++ php-src/ext/reflection/php_reflection.c Sat Jan 3 20:40:22 2009 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reflection.c,v 1.336 2009/01/03 20:03:45 helly Exp $ */ +/* $Id: php_reflection.c,v 1.337 2009/01/03 20:40:22 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -886,7 +886,7 @@ string_printf(str, "\n"); string_printf(str, "%s - Static Parameters [%d] {\n", indent, count); if (closure_this) { - string_printf(str, "%s Parameter #%d [ %v $this ]\n", indent, ++index, Z_OBJCE_P(closure_this)->name); + string_printf(str, "%s Parameter #%d [ %v $this ]\n", indent, index++, Z_OBJCE_P(closure_this)->name); } if (static_variables) { HashPosition pos; @@ -894,7 +894,7 @@ zstr 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 [ $%v ]\n", indent, index++, key); zend_hash_move_forward_ex(static_variables, &pos); @@ -1605,7 +1605,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); + } } } /* }}} */ @@ -5558,7 +5560,7 @@ php_info_print_table_start(); php_info_print_table_header(2, "Reflection", "enabled"); - php_info_print_table_row(2, "Version", "$Revision: 1.336 $"); + php_info_print_table_row(2, "Version", "$Revision: 1.337 $"); php_info_print_table_end(); } /* }}} */ @@ -5572,7 +5574,7 @@ NULL, NULL, PHP_MINFO(reflection), - "$Revision: 1.336 $", + "$Revision: 1.337 $", STANDARD_MODULE_PROPERTIES }; /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt?r1=1.2&r2=1.3&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.2 php-src/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt:1.3 --- php-src/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt:1.2 Fri Aug 8 12:42:40 2008 +++ php-src/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt Sat Jan 3 20:40:22 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