Hi Stefan,
It couldn't be done using early binding.
It should be done delaying __CLASS__ constant resolution till run-time.
Doing this we can even substitute he proposed ZEND_CLASS_NAME with
ZEND_FETCH_CONSTANT(__CLASS__). For default values we'll have just store
the corresponding constant.
I'll try to prepare a patch myself.
Thanks. Dmitry.
On 01/15/2012 02:22 AM, Stefan Marr wrote:
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);
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php