diff options
author | Xinchen Hui <laruence@php.net> | 2013-03-21 21:29:02 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2013-03-21 21:32:06 +0800 |
commit | 39a173b79bcb5b77ef28c83c7da65621e78e717a (patch) | |
tree | c23e5e4445d97bc11ef2034142e3b3864eeb2afe | |
parent | 7dce0194c815cdc75a780b6471660042aed7bd7a (diff) | |
download | php-git-39a173b79bcb5b77ef28c83c7da65621e78e717a.tar.gz |
Fix bug in reflectionClass relate to #64239
-rw-r--r-- | ext/reflection/php_reflection.c | 3 | ||||
-rw-r--r-- | ext/reflection/tests/bug64239.phpt | 44 |
2 files changed, 46 insertions, 1 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 25ecbad68e..6c4d806236 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1298,7 +1298,8 @@ static void reflection_method_factory(zend_class_entry *ce, zend_function *metho } MAKE_STD_ZVAL(name); MAKE_STD_ZVAL(classname); - ZVAL_STRING(name, method->common.function_name, 1); + ZVAL_STRING(name, (method->common.scope && method->common.scope->trait_aliases)? + zend_resolve_method_name(ce, method) : method->common.function_name, 1); ZVAL_STRINGL(classname, method->common.scope->name, method->common.scope->name_length, 1); reflection_instantiate(reflection_method_ptr, object TSRMLS_CC); intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC); diff --git a/ext/reflection/tests/bug64239.phpt b/ext/reflection/tests/bug64239.phpt new file mode 100644 index 0000000000..9acdc1987b --- /dev/null +++ b/ext/reflection/tests/bug64239.phpt @@ -0,0 +1,44 @@ +--TEST-- +Bug #64239 (ReflectionClass::getMethods() changed behavior) +--FILE-- +<?php +class A { + use T2 { t2method as Bmethod; } +} +trait T2 { + public function t2method() { + } +} + +class B extends A{ +} + +$obj = new ReflectionClass("B"); +print_r($obj->getMethods()); +print_r(($method = $obj->getMethod("Bmethod"))); +var_dump($method->getName()); +var_dump($method->getShortName()); +?> +--EXPECT-- +Array +( + [0] => ReflectionMethod Object + ( + [name] => Bmethod + [class] => A + ) + + [1] => ReflectionMethod Object + ( + [name] => t2method + [class] => A + ) + +) +ReflectionMethod Object +( + [name] => Bmethod + [class] => A +) +string(7) "Bmethod" +string(7) "Bmethod" |