Anyone can comment on a bug. Have a simpler test case? Does it
work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please
!

Your email address:MUST BE VALID

Solve the problem:40 - 24 = ?

Subscribe to this entry?

[2018-06-28 08:53 UTC] christian dot lerch89 at gmail dot com

Description:
------------
When the value of a trait attribute is a concatenation of self::class (or __CLASS__) and another string, the value of the very first instantiation persists.
This problem seems to be introduced at 7.1 and still shows up on 7.2.4.
You may try the example with >=7.0 here: http://sandbox.onlinephpfunctions.com/code/cced66bdfaf2dc5d09a042e4de1947bd8198b95d
Test script:
---------------
trait MyTrait {
protected $attr = self::class . 'Test';
public function test() {
return $this->attr;
}
}
class A {
use MyTrait;
}
class B {
use MyTrait;
}
$a = new A();
$b = new B();
Expected result:
----------------
ATest
BTest
Actual result:
--------------
ATest
ATest