Commit: 7886f46b560c51f235da35a33c8cd0e6479c9360 Author: Xinchen Hui <larue...@php.net> Wed, 31 Oct 2012 11:13:32 +0800 Parents: 440bbcd9e3c5392194774a77baf18b8ab3ccfb32 Branches: PHP-5.4
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7886f46b560c51f235da35a33c8cd0e6479c9360 Log: Fixed bug #63399 (ReflectionClass::getTraitAliases() incorrectly resolves traitnames) Bugs: https://bugs.php.net/63399 Changed paths: M NEWS M ext/reflection/php_reflection.c A ext/reflection/tests/bug63399.phpt M ext/reflection/tests/traits005.phpt Diff: diff --git a/NEWS b/NEWS index 74dab3c..7a1438a 100644 --- a/NEWS +++ b/NEWS @@ -33,6 +33,10 @@ PHP NEWS . Fixed bug #63297 (Phar fails to write an openssl based signature). (Anatoliy) +- Reflection: + . Fixed bug #63399 (ReflectionClass::getTraitAliases() incorrectly resolves + traitnames). (Laruence) + 18 Oct 2012, PHP 5.4.8 - CLI server: diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 7c99819..53b2389 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -4465,7 +4465,7 @@ ZEND_METHOD(reflection_class, getTraitAliases) zend_trait_method_reference *cur_ref = ce->trait_aliases[i]->trait_method; if (ce->trait_aliases[i]->alias) { - method_name_len = spprintf(&method_name, 0, "%s::%s", cur_ref->class_name, cur_ref->method_name); + method_name_len = spprintf(&method_name, 0, "%s::%s", cur_ref->ce->name, cur_ref->method_name); add_assoc_stringl_ex(return_value, ce->trait_aliases[i]->alias, ce->trait_aliases[i]->alias_len + 1, method_name, method_name_len, 0); } i++; diff --git a/ext/reflection/tests/bug63399.phpt b/ext/reflection/tests/bug63399.phpt new file mode 100644 index 0000000..393b861 --- /dev/null +++ b/ext/reflection/tests/bug63399.phpt @@ -0,0 +1,49 @@ +--TEST-- +Bug #63399 (ReflectionClass::getTraitAliases() incorrectly resolves traitnames) +--FILE-- +<?php +trait Trait1 { + public function run() {} + public function say() {} +} + +trait Trait2 { + public function run() {} + public function say() {} +} + +class MyClass +{ + use Trait1, Trait2 { + Trait1::run as execute; + Trait1::say insteadof Trait2; + Trait2::run insteadof Trait1; + Trait2::say as talk; + } +} + +$ref = new ReflectionClass('MyClass'); + +print_r($ref->getTraitAliases()); +print_r($ref->getTraits()); + +?> +--EXPECT-- +Array +( + [execute] => Trait1::run + [talk] => Trait2::say +) +Array +( + [Trait1] => ReflectionClass Object + ( + [name] => Trait1 + ) + + [Trait2] => ReflectionClass Object + ( + [name] => Trait2 + ) + +) diff --git a/ext/reflection/tests/traits005.phpt b/ext/reflection/tests/traits005.phpt index 1496a35..4cfa6c0 100644 --- a/ext/reflection/tests/traits005.phpt +++ b/ext/reflection/tests/traits005.phpt @@ -28,14 +28,14 @@ array(0) { class C3: array(1) { ["a1"]=> - string(10) "(null)::m1" + string(6) "T1::m1" } class C4: array(2) { ["a1"]=> - string(10) "(null)::m1" + string(6) "T1::m1" ["a2"]=> - string(10) "(null)::m2" + string(6) "T1::m2" } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php