com php-src: Fixed bug #69802 (Reflection on Closure::_ _invoke borks type hint class name): NEWS Z end/tests/bug69802.phpt ext/reflection/php_refl
ection.c

From: Date: Mon, 15 Jun 2015 12:44:44 +0000
Subject: com php-src: Fixed bug #69802 (Reflection on Closure::_ _invoke borks type hint class name): NEWS Z end/tests/bug69802.phpt ext/reflection/php_refl
ection.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87281@lists.php.net to get a copy of this message
Commit: 33e71d5c20ebdaaee9c4d12a82f65ae2cded7cbc Author: Dmitry Stogov <dmitry@zend.com> Mon, 15 Jun 2015 15:44:44 +0300 Parents: 562bffe60ed85ba89920fb3918229c544eec15e9 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=33e71d5c20ebdaaee9c4d12a82f65ae2cded7cbc Log: Fixed bug #69802 (Reflection on Closure::__invoke borks type hint class name) Bugs: https://bugs.php.net/69802 Changed paths: M NEWS A Zend/tests/bug69802.phpt M ext/reflection/php_reflection.c Diff: diff --git a/NEWS b/NEWS index e0f2a16..5ec8877 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ PHP NEWS extensions are loaded). (Laruence) . Fixed bug #69805 (null ptr deref and seg fault in zend_resolve_class_name). (Laruence) + . Fixed bug #69802 (Reflection on Closure::__invoke borks type hint class + name). (Dmitry) . Fixed bug #69761 (Serialization of anonymous classes should be prevented). (Laruence) . Fixed bug #69551 (parse_ini_file() and parse_ini_string() segmentation diff --git a/Zend/tests/bug69802.phpt b/Zend/tests/bug69802.phpt new file mode 100644 index 0000000..6143b0b --- /dev/null +++ b/Zend/tests/bug69802.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #69802 (Reflection on Closure::__invoke borks type hint class name) +--FILE-- +<?php +$f = function(stdClass $x) {}; +$r = new ReflectionMethod($f, '__invoke'); +var_dump($r->getParameters()[0]->getClass()); +?> +--EXPECT-- +object(ReflectionClass)#4 (1) { + ["name"]=> + string(8) "stdClass" +} diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 4c570d7..c8c5a52 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2620,7 +2620,10 @@ ZEND_METHOD(reflection_parameter, getClass) const char *class_name; size_t class_name_len; - if (param->fptr->type == ZEND_INTERNAL_FUNCTION) { + if (param->fptr->type == ZEND_INTERNAL_FUNCTION && + /* Closure::__invoke() reuses arg_info of user function and + * don't set ZEND_ACC_HAS_TYPE_HINTS flag */ + (param->fptr->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) { class_name = ((zend_internal_arg_info*)param->arg_info)->class_name; class_name_len = strlen(class_name); } else { @@ -2648,7 +2651,8 @@ ZEND_METHOD(reflection_parameter, getClass) } ce = ce->parent; } else { - if (param->fptr->type == ZEND_INTERNAL_FUNCTION) { + if (param->fptr->type == ZEND_INTERNAL_FUNCTION && + (param->fptr->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) { zend_string *name = zend_string_init(class_name, class_name_len, 0); ce = zend_lookup_class(name); zend_string_release(name);

« previous php.cvs (#87281) next »