mirror of
https://github.com/php/php-src.git
synced 2024-11-28 12:26:37 +08:00
- Fixed bug #49092 (ReflectionFunction fails to work with functions in fully qualified namespaces)
This commit is contained in:
parent
0b03346bf8
commit
adf8f72f14
2
NEWS
2
NEWS
@ -8,6 +8,8 @@ PHP NEWS
|
||||
- Fixed signature generation/validation for zip archives in ext/phar. (Greg)
|
||||
- Fixed memory leak in stream_is_local(). (Felipe)
|
||||
|
||||
- Fixed bug #49092 (ReflectionFunction fails to work with functions in fully
|
||||
qualified namespaces). (Kalle, Jani)
|
||||
- Fixed bug #49074 (private class static fields can be modified by using
|
||||
reflection). (Jani)
|
||||
- Fixed bug #49108 (2nd scan_dir produces seg fault). (Felipe)
|
||||
|
@ -1516,8 +1516,18 @@ ZEND_METHOD(reflection_function, __construct)
|
||||
fptr = (zend_function*)zend_get_closure_method_def(closure TSRMLS_CC);
|
||||
Z_ADDREF_P(closure);
|
||||
} else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len) == SUCCESS) {
|
||||
char *nsname;
|
||||
|
||||
lcname = zend_str_tolower_dup(name_str, name_len);
|
||||
if (zend_hash_find(EG(function_table), lcname, name_len + 1, (void **)&fptr) == FAILURE) {
|
||||
|
||||
/* Ignore leading "\" */
|
||||
nsname = lcname;
|
||||
if (lcname[0] == '\\') {
|
||||
nsname = &lcname[1];
|
||||
name_len--;
|
||||
}
|
||||
|
||||
if (zend_hash_find(EG(function_table), nsname, name_len + 1, (void **)&fptr) == FAILURE) {
|
||||
efree(lcname);
|
||||
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
|
||||
"Function %s() does not exist", name_str);
|
||||
|
12
ext/reflection/tests/bug49092.phpt
Normal file
12
ext/reflection/tests/bug49092.phpt
Normal file
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Bug #49092 (ReflectionFunction fails to work with functions in fully qualified namespaces)
|
||||
--FILE--
|
||||
<?php
|
||||
namespace ns;
|
||||
function func(){}
|
||||
new \ReflectionFunction('ns\func');
|
||||
new \ReflectionFunction('\ns\func');
|
||||
echo "Ok\n"
|
||||
?>
|
||||
--EXPECT--
|
||||
Ok
|
Loading…
Reference in New Issue
Block a user