mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
- Fixed bug #62892 (ReflectionClass::getTraitAliases crashes on importing trait methods as private)
This commit is contained in:
21
Zend/tests/bug62892.phpt
Normal file
21
Zend/tests/bug62892.phpt
Normal file
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Bug #62892 (ReflectionClass::getTraitAliases crashes on importing trait methods as private)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
trait myTrait {
|
||||
public function run() {}
|
||||
}
|
||||
|
||||
class myClass {
|
||||
use myTrait {
|
||||
MyTrait::run as private;
|
||||
}
|
||||
}
|
||||
$class = new \ReflectionClass('myClass');
|
||||
var_dump($class->getTraitAliases());
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(0) {
|
||||
}
|
||||
@@ -4464,8 +4464,10 @@ ZEND_METHOD(reflection_class, getTraitAliases)
|
||||
int method_name_len;
|
||||
zend_trait_method_reference *cur_ref = ce->trait_aliases[i]->trait_method;
|
||||
|
||||
method_name_len = spprintf(&method_name, 0, "%s::%s", cur_ref->class_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);
|
||||
if (ce->trait_aliases[i]->alias) {
|
||||
method_name_len = spprintf(&method_name, 0, "%s::%s", cur_ref->class_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++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user