Req #74340 [NEW]: Magic function __get have different behavior in php 7.1.x

From: Date: Thu, 30 Mar 2017 13:51:28 +0000
Subject: Req #74340 [NEW]: Magic function __get have different behavior in php 7.1.x
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208181@lists.php.net to get a copy of this message
From: x dot xiang at outlook dot com Operating system: macOS/Linux PHP version: 7.1.3 Package: Class/Object related Bug Type: Feature/Change Request Bug description:Magic function __get have different behavior in php 7.1.x Description: ------------ Does the recursive call to the magic method be allowed? Actual result in php 5.x and 7.0.x: __get test PHP Notice: Undefined property: Test::$test in /data1/data/playcrab/tmp/test4.php on line 10 __get test2 PHP Notice: Undefined property: Test::$test in /data1/data/playcrab/tmp/test4.php on line 12 Actual result in php 7.1.x: __get test PHP Notice: Undefined property: Test::$test in /data1/data/playcrab/tmp/test4.php on line 10 __get test2 __get test Test script: --------------- <?php class Test { public function __get($var) { static $first = true; echo '__get '.$var.PHP_EOL; if ($first) { $first = false; $this->$var; $this->{$var.'2'}; $this->$var; } } } $test = new Test; $test->test; Expected result: ---------------- __get test __get test __get test2 __get test Actual result: -------------- __get test PHP Notice: Undefined property: Test::$test in /data1/data/playcrab/tmp/test4.php on line 10 __get test2 __get test -- Edit bug report at https://bugs.php.net/bug.php?id=74340&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74340&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74340&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74340&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74340&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74340&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74340&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74340&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74340&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74340&r=support Expected behavior: https://bugs.php.net/fix.php?id=74340&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74340&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74340&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74340&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74340&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74340&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74340&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74340&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74340&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74340&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74340&r=mysqlcfg

« previous php.bugs (#208181) next »