php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72056 __get is called for testing if chained property is set
Submitted: 2016-04-19 10:17 UTC Modified: 2016-04-22 22:54 UTC
From: koubel at seznam dot cz Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 7.0.5 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: koubel at seznam dot cz
New email:
PHP Version: OS:

 

 [2016-04-19 10:17 UTC] 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)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-22 22:54 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2016-04-22 22:54 UTC] nikic@php.net
Already fixed in 7.0.6.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jun 02 22:01:27 2025 UTC