Bug #63911 [Com]: Ignore conflicting trait methods originationg from identical sub traits
| From: | keithdavis at solidtechservice dot com | Date: | Wed, 24 Dec 2014 05:15:31 +0000 |
| Subject: | Bug #63911 [Com]: Ignore conflicting trait methods originationg from identical sub traits | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189170@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63911&edit=1
ID: 63911
Comment by: keithdavis at solidtechservice dot com
Reported by: bitluni at bitluni dot net
Summary: Ignore conflicting trait methods originationg from
identical sub traits
Status: Verified
Type: Bug
Package: Class/Object related
Operating System: debian
PHP Version: 5.4.10
Block user comment: N
Private report: N
New Comment:
I suppose that would work, but that does still divert from the actual issue here - that there is
nothing to "override", as it's the same trait being used twice.
Previous Comments:
------------------------------------------------------------------------
[2014-12-22 21:10:51] mw dot wanrooij at vodafonevast dot nl
In my humble opinion, a solution/improvement would be that precedence order should not only be
appliccable to classes, but also to traits.
To expand on the given example at the start of this topic, when:
trait A
{
public function a(){}
public function b(){}
public function c(){}
public function z(){}
}
trait B
{
use A;
}
trait C
{
use A;
}
class D
{
use B, C;
}
The expected result here would be that methods in trait C override methods in trait B, unless
explicitly specified using the insteadof operator.
Shortened example using the insteadof operator:
class D
{
use B;
use C {
B::a insteadof C;
}
}
Here, the expected results would be that methods in trait C override methods in trait B, except for
method B::a() which is explicitly defined to be used instead of C::a()
If one would change which methods would override other methods, one would simply change the
precedence other, as with the example:
class D
{
use C;
use B {
C::a insteadof B;
}
}
Here, the expected results would be that methods in trait B override methods in trait C, except for
method C::a() which is explicitly defined to be used instead of B::a()
Am I making sense?
------------------------------------------------------------------------
[2014-10-29 19:30:22] keithdavis at solidtechservice dot com
I think the point here is that if I use the same trait twice because I use a trait that uses an
already used trait, it's the SAME method included twice.
------------------------------------------------------------------------
[2014-10-29 17:15:28] gaetane dot le dot grange at gmail dot com
I went into some detail here: http://stackoverflow.com/questions/20382202/php-trait-method-conflicts-trait-inheritance-and-trait-hierarchies
------------------------------------------------------------------------
[2014-10-29 16:08:01] jpauli@php.net
Can someone explain me what you expect as a result ?
For me, this is the right behavior, the engine has no way of differenciating between B::a() and
C::A() , you have to help it using 'insteadof'
------------------------------------------------------------------------
[2013-12-07 08:31:24] gaetaneislockedoutof at gmail dot com
I have this issue. It makes me very sad :'(
Windows 7 Home Premium Edition Service Pack 1, 64bit
PHP 5.5.6 / Apache/2.4.7 (Win32)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=63911
--
Edit this bug report at https://bugs.php.net/bug.php?id=63911&edit=1