Bug #74340 [Opn->Csd]: Magic function __get has different behavior in php 7.1.x

From: Date: Sun, 02 Apr 2017 11:31:20 +0000
Subject: Bug #74340 [Opn->Csd]: Magic function __get has different behavior in php 7.1.x
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208279@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74340&edit=1 ID: 74340 Updated by: nikic@php.net Reported by: x dot xiang at outlook dot com Summary: Magic function __get has different behavior in php 7.1.x -Status: Open +Status: Closed Type: Bug Package: Class/Object related Operating System: macOS/Linux PHP Version: 7.1.3 Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikita.ppv@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=fe46a7da78f037fe032f27c9b65667c675a6dd8d Log: Fixed bug #74340 Previous Comments: ------------------------------------------------------------------------ [2017-03-30 13:51:27] x dot xiang at outlook dot com 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 this bug report at https://bugs.php.net/bug.php?id=74340&edit=1

« previous php.bugs (#208279) next »