Bug #63652 [Opn]: Using twice the same trait causes fatal error.
| From: | laruence@php.net | Date: | Sat, 01 Dec 2012 05:52:37 +0000 |
| Subject: | Bug #63652 [Opn]: Using twice the same trait causes fatal error. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-175056@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
Updated by: laruence@php.net
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:
I think PHP had warn you about method collisions..
Previous Comments:
------------------------------------------------------------------------
[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