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

 ID:                 63652
 Comment by:         stealz at op dot pl
 Reported by:        stealz at op dot pl
 Summary:            Using twice the same trait causes fatal error.
 Status:             Open
 Type:               Bug
 Package:            Class/Object related
 Operating System:   Windows 7
 PHP Version:        5.4.9
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for your reply.
PHP had warned me indeed, but it doesn't change the fact that, as I wrote, this 
is exactly the same method of exactly the same trait, so it shouldn't be 
colliding at all.
Can you please prove me wrong?


Previous Comments:
------------------------------------------------------------------------
[2012-12-01 05:52:37] larue...@php.net

I think PHP had warn you about method collisions..

------------------------------------------------------------------------
[2012-12-01 05:52:32] larue...@php.net

I think PHP had warn you about method collisions..

------------------------------------------------------------------------
[2012-11-30 01:48:47] stealz at op dot pl

Description:
------------
I think PHP should check whether traits were used already (ex. in parent class) 
and ignore them instead using again. It causes fatal error due to collisions 
which are obvious, because trait name is the same.
What's interesting, collisions refer only to methods. PHP seems not to see the 
problem if double-used trait contains properties only.

Test script:
---------------
trait LifeOrganism {
        public $age; // it's fine
        #public function live() {} // uncomment to get Fatal error
}
                
trait Man {
        use LifeOrganism;
}

trait Elephant {
        use LifeOrganism;
}

class ElephantMan {
        use Man, Elephant;
}

Expected result:
----------------
Ignore trait which was already used.

Actual result:
--------------
Fatal error.


------------------------------------------------------------------------



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

Reply via email to