RE: [PHP-DEV] Traits and Properties
| From: | Jonathan Bond-Caron | Date: | Wed, 22 Dec 2010 15:39:46 +0000 |
| Subject: | RE: [PHP-DEV] Traits and Properties | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51115@lists.php.net to get a copy of this message | ||
On Mon Dec 20 06:21 PM, Stefan Marr wrote:
>
> ===== Handling of Properties/State =====
>
> This property handling was implemented in
> [[http://svn.php.net/viewvc?view=revision&revision=306476|SVN revision
> 306476]] and examples are given in the test cases.
>
+1
The E_STRICT warning seems to follow nicely the paper's view that a stateful
trait should be its own 'black-box':
http://scg.unibe.ch/archive/papers/Berg07eStatefulTraits.pdf
There are two remaining questions I have:
1) How do traits affect the reflection API?
2) Do we want to be able to declare trait requirements for properties and
methods? If so what syntax?
A note on the syntax proposed by Nathan:
trait require Foo
An option could be:
trait Foo {
require {
public $var;
function ratio();
}
function doFoo($v) {
$this->var = $v * $this->ratio();
}
}
trait Bar {
require interface Iterator;
}
The idea comes from:
http://code.google.com/p/es-lab/wiki/Traits
I found this trying to look for alternative keyword for 'require'.