Re: Re: [RFC] Validation for abstract trait methods
| From: | Levi Morrison via internals | Date: | Tue, 03 Mar 2020 21:39:50 +0000 |
| Subject: | Re: Re: [RFC] Validation for abstract trait methods | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108833@lists.php.net to get a copy of this message | ||
On Tue, Mar 3, 2020 at 8:01 AM Nikita Popov <nikita.ppv@gmail.com> wrote:
>
> On Fri, Feb 7, 2020 at 11:32 AM Nikita Popov <nikita.ppv@gmail.com> wrote:
>
> > Hi internals,
> >
> > I've sent a mail about this before, but as this turned into a bit of a
> > larger change (also allowing "abstract private" methods in traits) and
> > there's some backwards compatibility impact, I've created a proper RFC for
> > this:
> >
> > https://wiki.php.net/rfc/abstract_trait_method_validation
> >
>
> Based on Nicolas' feedback, I've adjusted the RFC to not validate the
> visibility of the method (only the signature and "static-ness"). The reason
> is outlined in the last paragraph of the Proposal section.
>
> With that done, I plan to open voting on this tomorrow, unless something
> new comes up.
>
> Regards,
> Nikita
To clarify, this the signature enforcement is only applied to abstract
methods that come from traits, correct? This code will remain valid?
```
trait CompareHelper {
function compareTo($obj): bool {}
}
class C1 {
use CompareHelper;
function compareTo(self $obj) {}
}
```
Notably, non-abstract methods will be able to change argument counts,
their type, the return type, all without restriction. Correct? I don't
particularly like code like this, but I've seen it out there on more
than one occasion.