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

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=74340&edit=1

 ID:                 74340
 Updated by:         [email protected]
 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 [email protected]
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.