Req #61943 [Opn]: Trait same property conflict in class extending
| From: | gron@php.net | Date: | Fri, 04 May 2012 23:28:50 +0000 |
| Subject: | Req #61943 [Opn]: Trait same property conflict in class extending | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-170200@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61943&edit=1
ID: 61943
Updated by: gron@php.net
Reported by: franssen dot roland at gmail dot com
Summary: Trait same property conflict in class extending
Status: Open
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Ubuntu
PHP Version: 5.4.2
-Assigned To:
+Assigned To: gron
Block user comment: N
Private report: N
New Comment:
Hi:
From my point of view, it is not the same property.
My understanding is that you are moving here very much in the area of the typical diamond problem of
multiple inheritance.
Theoretically, it is not clear whether the two properties should be handled as the same or not.
Why would you want to apply the trait a second time?
Best regards
Stefan
Previous Comments:
------------------------------------------------------------------------
[2012-05-04 20:07:42] franssen dot roland at gmail dot com
Description:
------------
Hi,
(version is actually 5.4RC9...)
The same property conflict happens when you have 2 traits (B uses A) where A defines the property,
class Foo uses A and class Bar uses B _and_ extends Foo.
I would love to see the strict standard to be removed in this situation; how can a property have a
conflict with itself?
Test script:
---------------
<?php
trait A {
public $prop;
}
trait B {
use A;
}
class Foo {
use A;
}
class Bar extends Foo {
use B;
}
Expected result:
----------------
<void>
Actual result:
--------------
Strict Standards: Foo and B define the same property ($prop) in the composition of Bar. This might
be incompatible, to improve maintainability consider using accessor methods in traits instead.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61943&edit=1