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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC