Re: RFC: Traits for PHP

From: Date: Wed, 20 Feb 2008 19:59:51 +0000
Subject: Re: RFC: Traits for PHP
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-35653@lists.php.net to get a copy of this message
Hello Stefan, so at th eend of the day users will get renaming and will abuse it. That said I am wondering if at the beginning we might want to do Traits without aliasing and dropping. If we feel it gets necessary we probbaly might want to support a syntax like: 'trait_method' => false 'trait_method' => 'new_name' 'trait_method' => array('new_name', 'trait_method' I am suggesting this because it is more what people expect to find. And it is easier to understand imo. marcus Tuesday, February 19, 2008, 10:59:20 PM, you wrote: > Hi Evert, >> Aliasing doesn't make a lot of sense, as you can always : >> >> function newMethod() { >> return $this->oldMethod(); >> } > Don't think so. > You do use aliasing to handle conflicts and in the case of a conflict > there is no oldMethod. > trait A { > public function foo() {echo 'foo';} > } > trait B { > public function foo() {echo 'fooBar';} > } > class MyClass { > use A; > use B { > !foo, fooBar => foo > } > } > The result will be at runtime: > class MyClass { > public function foo() {echo 'foo';} > public function foo() {echo 'fooBar';} > } > Here you can't do something like this: > class MyClass { > use A; > use B; > } > since eventually there wont be any method in MyClass. Best regards, Marcus

« previous php.internals (#35653) next »