Re: Urgent patch for traits in PHP 5.4

From: Date: Sat, 14 Jan 2012 00:24:35 +0000
Subject: Re: Urgent patch for traits in PHP 5.4
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-57365@lists.php.net to get a copy of this message
Hi Stas: On 13 Jan 2012, at 19:53, Stas Malyshev wrote: > 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. Yes looks like another hole in the things I covered :-/ The attached test defines the intended behavior. Like you said, __CLASS__ is expected to give the using class. My testing covered so far only the handling of __CLASS__ in methods.

« previous php.internals (#57365) next »