The question here is how to handle property accesses, in particular accesses to unspecified properties. I actually would expect to have a lookup mechanism which first looks in the trait, and if the property is not found there, its going to the object. I expect this behavior, because it is similar to what we have with inheritance and properties defined by a superclass.

If a property is not jet defined, I would expect it to be created in the most inner scope, like local variables. On the other hand, I also would expect, as in inheritance, properties to be found defined by super classes, or the class which defines the composition.

But this only my intuitive solution, so this could of course be specified different.

Best regards
Stefan

Hi,

I see this in a much simpler fashion. Treat traits as a preprocessor step semantically.

Internally, trait methods on multiple classes may point to the same method to save resources, but in my opinion there's no need to complicate matter by introducing new resolution rules, scopes, and so on.
The way I see it:

1) Property/Method name conflicts on trait/class, within the class including the trait raises Fatal Error. 2) Extending classes can override the property/method, unless it's a final method, just like as if they override normal parent class property/method. 3) There's a single space for a class property and its trait properties, so access works as if it was all class properties.

Feedback?

Regards,
Stan Vassilev

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to