Bug #55183 [Opn->Asn]: Aliasing traits
| From: | felipe@php.net | Date: | Mon, 11 Jul 2011 22:15:32 +0000 |
| Subject: | Bug #55183 [Opn->Asn]: Aliasing traits | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-161812@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55183&edit=1
ID: 55183
Updated by: felipe@php.net
Reported by: php at bouchery dot com
Summary: Aliasing traits
-Status: Open
+Status: Assigned
Type: Bug
Package: Class/Object related
Operating System: Windows XP
PHP Version: 5.4.0alpha1
-Assigned To:
+Assigned To: gron
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2011-07-11 16:50:52] php at bouchery dot com
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 this bug report at https://bugs.php.net/bug.php?id=55183&edit=1