Re: [RFC] Traits with interfaces
| From: | Markus Fischer | Date: | Wed, 17 Feb 2016 15:36:50 +0000 |
| Subject: | Re: [RFC] Traits with interfaces | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91250@lists.php.net to get a copy of this message | ||
Hello,
On 17.02.16 15:25, Kevin Gessner wrote:
> I've noticed s pattern in Etsy's code and elsewhere, where a trait provides
> a common implementation of an interface. Classes that use the trait are
> required to also explicitly declare the interface to benefit. I propose
> that traits be permitted to declare and implement interfaces.
I like this, because this is a pattern I experienced myself.
In my code I've:
- interface GroupBulkFilterable { .. }
- trait GroupBulkFilterTrait { .. }
and later
class AbstractModelBridge implements ModelBridge, GroupBulkFilterable {
use GroupBulkFilterTrait;
Would use the interface on the trait in an instant.
> Classes that
> use such a trait would then implement the interface, as though it were
> declared on the class, without declaring the interface explicitly.
I don't like this. I prefer explicit over implicit.
I would still see value in the first point only (but haven't thought
that through ...).
cheers,
- Markus