Stas,

Thank you for looking into it and finding out a new problem :)
I'll take a look into it and will try to fix.

Dmitry.

On 01/13/2012 10:53 PM, Stas Malyshev wrote:
Hi!

As I understood the copying was done only for proper handling of
__CLASS__ constant in trait methods. I think it's too radical solution.
I've introduced ZEND_CLASS_NAME instruction instead and made op_arrays
to share their opcodes (in the same way as inherited methods). The only
difference that methods from traits may be renamed.

I've done some checks and discovered __CLASS__ behaves somewhat
strangely with traits. COnsider this code:

<?
trait foo {
public $bar = __CLASS__;
function bar() { var_dump($this->bar); }
}

class foofoo {
use foo;
}

class foofoo2 {
use foo;
}

$a = new foofoo();
$a->bar();
$a = new foofoo2();
$a->bar();
echo "OK!";

Before the patch, it prints $this->bar as NULL. After the patch, I get:

Fatal error: Invalid binding type in - on line 5

Both behaviors seem to be wrong, as __CLASS__ works as constant in
regular classes. Looks like even before the patch __CLASS__ handling
wasn't correct, but patch also seems to break something.


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to