Edit report at https://bugs.php.net/bug.php?id=55183&edit=1

 ID:                 55183
 Updated by:         fel...@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

Reply via email to