Re: Traits and Properties
| From: | Matthew Weier O'Phinney | Date: | Mon, 20 Dec 2010 13:53:58 +0000 |
| Subject: | Re: Traits and Properties | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51094@lists.php.net to get a copy of this message | ||
On 2010-12-19, Stefan Marr <php@stefan-marr.de> wrote:
> On 19 Dec 2010, at 17:22, Matthew Weier O'Phinney wrote:
> > Exactly. I wouldn't default to public on conflicts, though -- just with
> > the highest declared visibility (e.g., if one trait defines as private
> > and the other as protected, protected wins).
> I am currently actually implementing the most restricted proposal: all
> differences in the property definition will lead to a fatal error.
>
> The reasoning behind this is, that the semantics of state is not
> predictable and all changes in the class/traits hierarchies which are
> incompatible should give the developer an immediate feedback, i.e.,
> make potentially incompatible code break. That is not the most
> 'dynamic' of all possible solutions but seems to fit with the rest of
> PHP.
That makes sense to me as well; having conflicting properties due to
multiple traits implementing them is a good way to lead to inconsistency
and difficult to test/predict code.
> What I have in mind is also not how the methods integrate into the
> inheritance chain, thus, a property in the body of the class does not
> override all property definitions in traits (this is the case for
> methods). I think that will be useful for the very same reason. And
> well, I hope an educative error message will steer the crowed in the
> right direction to use accessors.
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc