mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Fixed bug #69802 (Reflection on Closure::__invoke borks type hint class name)
This commit is contained in:
parent
562bffe60e
commit
33e71d5c20
2
NEWS
2
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
|
||||
|
13
Zend/tests/bug69802.phpt
Normal file
13
Zend/tests/bug69802.phpt
Normal file
@ -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"
|
||||
}
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user