Re: RFC: Traits for PHP

From: Date: Wed, 20 Feb 2008 08:44:31 +0000
Subject: Re: RFC: Traits for PHP
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-35642@lists.php.net to get a copy of this message
On 20.02.2008, at 09:28, Stefan Marr wrote:
Hi Lars,
What about abstract methods in traits? I think this could be handy to enforce the user class implement a data getter. trait Foo { public function doSomething() {
      return str_replace("foo", "bar", $this->_getString());
} abstract protected _getString(); } class Consumer { use Foo; protected function _getString() {
       return "foo";
} } What do you think?
I am sorry :) This part has been missing in the RFC. But is already implemented in the patch and supposed to work exactly like you has described it.
Maybe its best to first leave out interfaces/abstract etc. Start simple, see how things get used, get more comfortable with the feature and then see about potentially expanding it. regards, Lukas

« previous php.internals (#35642) next »