- Fixed bug #49092 (ReflectionFunction fails to work with functions in fully qualified namespaces)

This commit is contained in:
Jani Taskinen 2009-08-01 01:45:22 +00:00
parent 0b03346bf8
commit adf8f72f14
3 changed files with 25 additions and 1 deletions

2
NEWS
View File

@ -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)

View File

@ -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);

View 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