Bug #72056 [Opn->Csd]: __get is called for testing if chained property is set
| From: | nikic@php.net | Date: | Fri, 22 Apr 2016 22:54:05 +0000 |
| Subject: | Bug #72056 [Opn->Csd]: __get is called for testing if chained property is set | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200698@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72056&edit=1
ID: 72056
Updated by: nikic@php.net
Reported by: koubel at seznam dot cz
Summary: __get is called for testing if chained property is
set
-Status: Open
+Status: Closed
Type: Bug
Package: *General Issues
Operating System: Linux
PHP Version: 7.0.5
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Already fixed in 7.0.6.
Previous Comments:
------------------------------------------------------------------------
[2016-04-19 10:17:29] koubel at seznam dot cz
Description:
------------
For classes with implemented __get and __isset, __get is automatically called when testing only if
chained overloaded properties are set, despite the first property in chain doesn't exist. There
is no reason to call __get anymore.
It's there from the beginning of __get/__isset, So maybe it's feature, but undocumented?
Test script:
---------------
class Xstd {}
class XOverloading
{
function __isset($name)
{
return FALSE;
}
function __get($name)
{
trigger_error('Error', E_USER_WARNING);
}
}
$obj = new Xstd();
var_dump(isset($obj->prop1->prop2));
$obj = new XOverloading();
var_dump(isset($obj->prop1->prop2));
Expected result:
----------------
bool(false)
bool(false)
Actual result:
--------------
bool(false)
Warning: Error in .... on line 13
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72056&edit=1