Bug #74872 [NEW]: First Trait wins on importing same methods with diff alias

From: Date: Fri, 07 Jul 2017 04:00:05 +0000
Subject: Bug #74872 [NEW]: First Trait wins on importing same methods with diff alias
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209876@lists.php.net to get a copy of this message
From: asj dot ricardo at gmail dot com Operating system: any PHP version: 7.2.0alpha3 Package: Scripting Engine problem Bug Type: Bug Bug description:First Trait wins on importing same methods with diff alias Description: ------------ If we use: use Trait1 { Trait1::init as private method1trait1; } use Trait2 { Trait2::init as public method1trait2; } works. Test script: --------------- <?php trait Trait1 { public function init() { echo("Trait1 - init\n"); } } trait Trait2 { public function init() { echo("Trait2 - init\n"); } } class Test { use Trait1 { init as private method1trait1; } use Trait2 { init as public method1trait2; } final public function __construct() { $this->init(); $this->method1trait1(); $this->method1trait2(); } public function init() { echo("Test - init\n"); } } $test = new Test(); $reflection = new ReflectionClass( $test ); foreach($reflection->getTraitAliases() as $k => $v) { echo $k.' => '.$v."\n"; } Expected result: ---------------- Test - init Trait1 - init Trait2 - init method1trait1 => Trait1::init method1trait2 => Trait2::init Actual result: -------------- Test - init Trait1 - init Trait1 - init method1trait1 => Trait1::init method1trait2 => Trait1::init -- Edit bug report at https://bugs.php.net/bug.php?id=74872&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74872&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74872&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74872&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74872&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74872&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74872&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74872&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74872&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74872&r=support Expected behavior: https://bugs.php.net/fix.php?id=74872&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74872&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74872&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74872&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74872&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74872&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74872&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74872&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74872&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74872&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74872&r=mysqlcfg

« previous php.bugs (#209876) next »