Bug #74872 [Opn->Ver]: First Trait wins on importing same methods with diff alias

From: Date: Fri, 07 Jul 2017 04:13:53 +0000
Subject: Bug #74872 [Opn->Ver]: First Trait wins on importing same methods with diff alias
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209877@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74872&edit=1 ID: 74872 Updated by: requinix@php.net Reported by: asj dot ricardo at gmail dot com Summary: First Trait wins on importing same methods with diff alias -Status: Open +Status: Verified Type: Bug Package: Scripting Engine problem Operating System: any -PHP Version: 7.2.0alpha3 +PHP Version: 7.1.7 Block user comment: N Private report: N New Comment: https://3v4l.org/bbc88 Previous Comments: ------------------------------------------------------------------------ [2017-07-07 04:00:05] asj dot ricardo at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=74872&edit=1

« previous php.bugs (#209877) next »