On Mon Apr 12 05:16 AM, Stefan Marr wrote:
>
> On 12 Apr 2010, at 10:39, Lukas Kahwe Smith wrote:
> > On 12.04.2010, at 10:34, Derick Rethans wrote:
> >> Hi!
> >>
> But just as a quick response, without aliasing, there would be no way
> to use a conflicting method from a trait.
> On first sight, that is not a really good thing.
Hi Stefan, is it possible to have renaming and aliasing?
Some context, say we have:
trait Something {
function renameIssue() {
$method = 'call';
$this->$method();
call_user_func(array($this, $method));
}
function call () {
echo "a";
}
}
class Foo {
use Something {
function call() as call2();
}
}
With renaming:
$f = new Foo;
$f->call2(); // a
$f->renameIssue(); // call() method does not exist
With aliasing:
$f = new Foo;
$f->call(); // a
$f->call2(); // a
$f->renameIssue(); // a
While aliasing prevents the error, the syntax could re-use the 'clone'
keyword:
class Foo {
use Something {
function call() clone call2();
}
}
So we'd have both behaviors:
class Foo {
use Something {
function call() as call2();
function call() clone call3();
}
}
We have call(), call2(), call3()
class Foo {
use Something {
function call() as call2();
}
}
We have call2()
Other than that, the traits proposal still feels incomplete compared to
grafts since from Stefan's research: "the lack of state means that virtually
all traits are incomplete"
It's still a great step if the current proposal (methods only) gets
committed.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php