Bug #77399 [NEW]: __get and __set defined in traits can't access private variables from class

From: Date: Wed, 02 Jan 2019 15:50:35 +0000
Subject: Bug #77399 [NEW]: __get and __set defined in traits can't access private variables from class
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218750@lists.php.net to get a copy of this message
From: cfrenette at azorus dot com Operating system: Windows 10 18305 PHP version: 7.3.0 Package: *General Issues Bug Type: Bug Bug description:__get and __set defined in traits can't access private variables from class Description: ------------ If you have a __get or __set method defined in a trait, they can no longer access private/protected variables defined in the class that implements them. This worked < 7.3. I wasn't able to find any information on this breaking change in the PHP 7.3 changelog. Test script: --------------- trait T { public function __test($name) { return $this->$name; } } class Test { use T; private $test = 'asdf'; } $test = new Test(); echo $test->test; Expected result: ---------------- 'asdf' is echoed. Actual result: -------------- PHP Warning: Uncaught Error: Cannot access private property Test::$test in php shell code:1 -- Edit bug report at https://bugs.php.net/bug.php?id=77399&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77399&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77399&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77399&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77399&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77399&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77399&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77399&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77399&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77399&r=support Expected behavior: https://bugs.php.net/fix.php?id=77399&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77399&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77399&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77399&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77399&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77399&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77399&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77399&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77399&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77399&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77399&r=mysqlcfg

« previous php.bugs (#218750) next »