Re: Urgent patch for traits in PHP 5.4
| From: | Stefan Marr | Date: | Sat, 14 Jan 2012 22:22:25 +0000 |
| Subject: | Re: Urgent patch for traits in PHP 5.4 | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-57366@lists.php.net to get a copy of this message | ||
Hi Dmitry:
On 14 Jan 2012, at 01:24, Stefan Marr wrote:
> On 13 Jan 2012, at 19:53, Stas Malyshev wrote:
>
>> trait foo {
>> public $bar = __CLASS__;
>> }
>
> Breakpoint 3, zend_do_early_binding () at zend_compile.c:4602
> 4602 zend_error(E_COMPILE_ERROR, "Invalid binding type");
> (gdb) p opline->opcode
> $1 = 159 '?' // == ZEND_CLASS_NAME
>
What would be the best approach to handle the case of property definitions?
I was thinking that we might want to handle that in zend_do_early_binding but usually these ops get
changed to NOPs after they have been evaluated.
And that's not what we need when the op_arrays are shared, I think.
However, the current implementation of ZEND_CLASS_NAME you proposed relies on EG(scope) which is not
set for the case below.
I might be able to look into it further on Monday, but not earlier, unfortunately.
Best regards
Stefan
trait Foo {
public $c = __CLASS__;
}
class Bar {
use Foo;
}
$bar = new Bar();
var_dump($bar);
--
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: +32 2 629 2974
Fax: +32 2 629 3525