php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32913 properties via __get and __set methods in one expression won't work
Submitted: 2005-05-02 14:11 UTC Modified: 2005-05-13 01:00 UTC
Votes:3
Avg. Score:4.0 ± 1.4
Reproduced:2 of 3 (66.7%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: marius at distance dot ktu dot lt Assigned:
Status: No Feedback Package: Class/Object related
PHP Version: 5.0.3 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: marius at distance dot ktu dot lt
New email:
PHP Version: OS:

 

 [2005-05-02 14:11 UTC] marius at distance dot ktu dot lt
Description:
------------
Note: you might say this is a duplicate of #28444, but i don't think it's not a bug so please read carefully what i've written before doing that and if you say it's a duplicate, please explain specificaly why... thanks.
---

when i traverse object tree with overloaded properties, i can't assign a value to complex properties (i.e. $a->b->c). i don't see why this should be a problem for php...

I don't get why do you say it's not a bug? Consider my reproduce code.

why do the first and second property accessors work and the third (final) one does not?
as i understand the final statement ($a->a->a = "";) should do:
$a->__get("a")->__set("a", "");

so what's wrong with that? no recursive __get or __set, everything should work by specification... or am i wrong? if so, where?

Reproduce code:
---------------
<?php
class A
{
	function __get($name)
	{
		return new A();
	}
	function __set($name, $value)
	{
	}
}
$a= new A();
$a->a->a; // only __get = ok
$a->a = ""; // only __set = ok
$a->a->a = ""; // __get and __set = error
?>

Expected result:
----------------
the code should work ok.

Actual result:
--------------
Fatal error: Cannot access undefined property for object with overloaded property access in test.php on line 15

this error only happens if php would need to call __get and __set of some classes (sequentially not recursively) to resolve one (lhs) expression.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-05 20:24 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip

Can't reproduce with latest 5.0 & HEAD CVS.
 [2005-05-13 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 07:01:28 2025 UTC