Re: On abstract methods defined on traits
| From: | Christoph M. Becker | Date: | Fri, 03 Aug 2018 18:22:27 +0000 |
| Subject: | Re: On abstract methods defined on traits | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-103037@lists.php.net to get a copy of this message | ||
On 03.08.2018 at 19:08, Pedro Magalhães wrote:
> On the documentation about traits there is a mention to: "Traits support
> the use of abstract methods in order to impose requirements upon the
> exhibiting class." in
>
> https://secure.php.net/manual/en/language.oop5.traits.php#language.oop5.traits.abstract
>
> However, this is not true, and it has never been since traits were
> introduced (https://3v4l.org/tYAmu).
>
> There is a related bug report in
> https://bugs.php.net/bug.php?id=75449
>
> What currently happens is that (like with normal methods), the method on
> the receiving class is used and the method from the trait is simply ignored.
Yes. However, if the class using the trait would not implement the
method, a compile time error would be thrown.
> Although this can be fixed, I wanted your opinion on it as this would be
> the only thing from traits that would impose anything on the receiving
> class and conflicts with the normal precedence rules.
Frankly, I don't understand what this bug report is about,
<https://3v4l.org/38lmA> looks pretty much expected (note
that the error
message is totally different from what has been reported; there is no
class D in the reproduce script).
--
Christoph M. Becker