I agree. with Sebastian. I'm personally a big fan of using traits as the
implementation mechanism for interfaces (i.e. implement the interfaces
methods in a trait, then use that trait in a class that implements the
interface), but I don't think there is anything positive to gain from
having the trait actually implement the interface.

On Wed, Feb 17, 2016 at 9:34 AM Sebastian Bergmann <sebast...@php.net>
wrote:

> Am 17.02.2016 um 15:25 schrieb Kevin Gessner:
> > Hello internals team!  I'd like to propose an RFC to allow traits to
> > implement interfaces.
>
>  I think that would violate "The Flattening Property" [1], meaning
>  that the fact that a class uses a trait must not be noticable by a
>  user of that class.
>
>  Also bear in mind that explicit is better than implicit. Two
>  explicit declarations, "implements <interface>" and "uses <trait>",
>  makes it obvious from looking at the code of a class that is
>  provides a specific API and uses a trait for its implementation.
>
> Exactly. Not to mention that interfaces are "types" (i.e. $object
instanceof MyInterface will be true if $object is an instance of a class
that implements MyInterface) while traits are not. By moving the
"implements MyInterface" into the trait, you "hide" and important attribute
of the class that should be obvious and explicit.


>  --
>  [1] https://wiki.php.net/rfc/horizontalreuse
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
-- Chase
chasepee...@gmail.com

Reply via email to