Bug #63652 [Com]: Using twice the same trait causes fatal error.
| From: | stealz at op dot pl | Date: | Sat, 01 Dec 2012 14:05:28 +0000 |
| Subject: | Bug #63652 [Com]: Using twice the same trait causes fatal error. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-175061@lists.php.net to get a copy of this message | ||
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] laruence@php.net
I think PHP had warn you about method collisions..
------------------------------------------------------------------------
[2012-12-01 05:52:32] laruence@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