Bug #76539 [NEW]: Trait attribute is set incorrectly when using self::class with another string

From: Date: Thu, 28 Jun 2018 08:53:34 +0000
Subject: Bug #76539 [NEW]: Trait attribute is set incorrectly when using self::class with another string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216000@lists.php.net to get a copy of this message
From: christian dot lerch89 at gmail dot com Operating system: Ubuntu 18.04 PHP version: 7.1Git-2018-06-28 (Git) Package: Scripting Engine problem Bug Type: Bug Bug description:Trait attribute is set incorrectly when using self::class with another string 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 -- Edit bug report at https://bugs.php.net/bug.php?id=76539&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76539&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76539&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76539&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76539&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76539&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76539&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76539&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76539&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76539&r=support Expected behavior: https://bugs.php.net/fix.php?id=76539&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76539&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76539&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76539&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76539&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76539&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76539&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76539&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76539&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76539&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76539&r=mysqlcfg

« previous php.bugs (#216000) next »