Re: Re: [RFC] Traits with interfaces

From: Date: Fri, 04 Mar 2016 10:06:16 +0000
Subject: Re: Re: [RFC] Traits with interfaces
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-91496@lists.php.net to get a copy of this message
Davey Shafik wrote on 04/03/2016 07:17:
1. If you simply alias (use foo { bar as bat; }) then you end up with an *additional* method with the new name, the trait method as defined is still brought in, and_will_ override inherited methods of the same name.
Here's a clearer example of this: https://3v4l.org/RKHPt Unfortunately, you can't even use "insteadof" to directly bring the parent method back in [https://3v4l.org/qOS5T], but you can stub it out with a direct call to parent:: [https://3v4l.org/s9i4N].
3. Doing this (visibility + name)_only_ gives you the new method, which is _different_ behavior to #1
I can't reproduce this: if I say "bar as private bat", the trait's bar still shows up, and is public, just as in the previous example: https://3v4l.org/1jH6o Your examples are rather confusing because they are effectively applying the same trait twice, at different levels of the hierarchy; I'm not sure this is a particularly likely scenario, or relevant to how interfaces should behave. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#91496) next »