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
 [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: Fri Apr 26 00:01:30 2024 UTC