Re: RFC: Traits for PHP
| From: | Stefan Marr | Date: | Tue, 19 Feb 2008 21:59:20 +0000 |
| Subject: | Re: RFC: Traits for PHP | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-35622@lists.php.net to get a copy of this message | ||
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.