summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2012-10-31 11:13:32 +0800
committerXinchen Hui <laruence@php.net>2012-10-31 11:13:32 +0800
commit7886f46b560c51f235da35a33c8cd0e6479c9360 (patch)
treee16ca150b1f6c07b059885033fe3facaf2124d2c /ext/reflection
parent440bbcd9e3c5392194774a77baf18b8ab3ccfb32 (diff)
downloadphp-git-7886f46b560c51f235da35a33c8cd0e6479c9360.tar.gz
Fixed bug #63399 (ReflectionClass::getTraitAliases() incorrectly resolves traitnames)
Diffstat (limited to 'ext/reflection')
-rw-r--r--ext/reflection/php_reflection.c2
-rw-r--r--ext/reflection/tests/bug63399.phpt49
-rw-r--r--ext/reflection/tests/traits005.phpt6
3 files changed, 53 insertions, 4 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 7c9981924d..53b2389d63 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 0000000000..393b861690
--- /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 1496a35ec9..4cfa6c04f0 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"
}