> > Personally I like everything but one tiny piece, that is you do '!method'
> > to ignore a method from a trait. Since renaming happens in a php array like
> > style I would prefer to have that approach apply for ignoring methods as
> > well. The way to do that imo is 'method=>false' or 'method=>NULL' which both
> > should be obvious to PHP programmers that heard about Traits.
>
> The irritating thing is that currently it would be null => 'oldmethod'.
> This is what I would critisize in general. I would prefer
> 'oldMethodName' => 'newMethodName' instead. 'oldMethodName' => null
> would be really cool.
It is not renaming is aliasing :)

Feels like I should give some thoughts on why renaming is not a good idea.
The question is, how should renaming work and in which scope is it applied?
Renaming would imply to adjust all references to a method name in all
methods of one composition. A composition are all methods flattened
into a class from one specific trait usage (including all methods from
traits the included trait is using). Ok this is the scope. Now we
would need to adjust all those method bodies, find all method calls on
$this->oldMethodName() and change them to $this->newMethodName().
Think this would be possible, yes.
But think the original traits idea goes a step further.
By excluding a method from a trait it is possible to mesh traits
together and build compositions where the result is a interleaving
construct, like gears.
The problem with renaming is, you will have no chance to achieve such
a meshed situation without additional glue code.

Excluding a trait method can be thought of as punching a hole into
your class which is either filled by another trait or by a method
defined in the class itself.

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

Reply via email to