On Wed, Feb 17, 2016, at 01:05 PM, Kevin Gessner wrote: > On Wed, Feb 17, 2016 at 9:25 AM, Kevin Gessner <kgess...@etsy.com> wrote: > > > Hello internals team! I'd like to propose an RFC to allow traits to > > implement interfaces. > > > > I've created a proper RFC wiki page here with the draft: > https://wiki.php.net/rfc/traits-with-interfaces > > It includes more detail and several example code snippets. Thanks all > for > your feedback so far.
Thanks, Kevin. At the risk of a "me too" post, I would also be in favor of allowing traits to declare an interface but NOT in favor of a use-ing class implicitly implementing the interface as a result. I'd rather the class still need to self-declare the interface; that it uses a trait to fulfill that contract is irrelevant to the outside world. At that point, the benefit becomes two-fold: 1) Communicate to users of the trait what the intent of the trait is: To provide the boilerplate for some interface, or portion thereof. This could be covered by PHPDoc, potentially, and I've suggested the same for PSR-5 before. 2) Ask the engine to do a syntax check on the class to make sure I did not forget something or screwed up in some way. That is, not fulfilling the interface on the trait would cause a parse error (or an error in my IDE), forcing me to fix my bug before I even try running it. PHPDoc would NOT have this benefit. Thus I feel this addition does have value that a PHPDoc alternative would not. --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php