Bug #55183 [NEW]: Aliasing traits

From: Date: Mon, 11 Jul 2011 20:50:52 +0000
Subject: Bug #55183 [NEW]: Aliasing traits
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-161810@lists.php.net to get a copy of this message
From: Operating system: Windows XP PHP version: 5.4.0alpha1 Package: Class/Object related Bug Type: Bug Bug description:Aliasing traits Description: ------------ I have 2 traits with the same method name. I don't want to keep one and rename (alias) the other, but rename both. use X, Y { X::set as setX; Y::set as setY; } Test script: --------------- <?php trait X { protected $_x = 0; public function set($x) { $this->_x = $x; } } trait Y { protected $_y = 0; public function set($y) { $this->_y = $y; } } class MyClass { use X, Y { X::set as setX; Y::set as setY; } } ?> Expected result: ---------------- MyClass with 2 method and 2 properties : class MyClass { protected $_x = 0; protected $_y = 0; public function setX($x) { $this->_x = $x; } public function setY($y) { $this->_y = $y; } } Actual result: -------------- PHP Fatal error: Trait method set has not been applied, because there are collisions with other trait methods on MyClass -- Edit bug report at https://bugs.php.net/bug.php?id=55183&edit=1 -- Try a snapshot (PHP 5.2): https://bugs.php.net/fix.php?id=55183&r=trysnapshot52 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55183&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55183&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55183&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55183&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55183&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55183&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55183&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55183&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55183&r=support Expected behavior: https://bugs.php.net/fix.php?id=55183&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55183&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55183&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55183&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55183&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55183&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55183&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55183&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55183&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55183&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55183&r=mysqlcfg Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55183&r=trysnapshot54

« previous php.bugs (#161810) next »