Hi Chase and Larry, On Thu, Feb 18, 2016 at 10:11 AM, Chase Peeler <chasepee...@gmail.com> wrote:
> On Thu, Feb 18, 2016 at 5:35 AM Larry Garfield <la...@garfieldtech.com> > wrote: > 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. > > > I agree, in theory, but I also think we introduce confusion. Every other OO > rule says you get "everything*" from what you are using (extending a > subclass gets you all the parent classes, implementing an interface that > extends an interface gets you the parent interface, using a trait that uses > a trait gets you both traits, etc). Perhaps we need a different keyword? > I'm wary of a new keyword, particularly because this situation isn't really that different from what "implements" means. I think if we wanted to go down the route of new syntax, I'd want to expand the `use` statement for traits to include or exclude any interfaces that a trait provides. But I don't think a syntax change is worth it for this feature, for the cognitive and language overhead. > [snip] > > 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. > > > > Agreed > > > 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. > > > > Good point. I was of the opinion "we can just use comments to declare > intent," but hadn't really thought of using the engine in this way. It > makes sense. > That makes sense -- I like having the language enforce intent, rather than just comments (which always rot, in my experience). > > > > > --Larry Garfield > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > -- Chase > chasepee...@gmail.com >