ID: 46570 User updated by: ms419 at freezone dot co dot uk Reported By: ms419 at freezone dot co dot uk Status: Bogus -Bug Type: Scripting Engine problem +Bug Type: Feature/Change Request Operating System: Debian PHP Version: 5.2.6 New Comment:
Thank you for explaining, lbarnaud. After some more testing, I confirmed that calling __get(<name>) inside __get(<name>) does indeed return null, although __get(<otherName>) inside __get(<name>) does not - it returns the value as expected. I would like to change this bug report to a feature/change request. I want __get(<name>) inside __get(<name>) to get called as expected. My own __get() function already guards against infinite recursion. By not calling the function and returning null instead, PHP is unnecessarily protecting me from doing something which I actually want to do... Previous Comments: ------------------------------------------------------------------------ [2008-11-14 06:36:02] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. This is because you are fetching $this->repository in __get(). This calls __get() inside of __get(), which returns null. Use $this->values[$name] instead in __get(). ------------------------------------------------------------------------ [2008-11-14 01:53:18] ms419 at freezone dot co dot uk Description: ------------ I have a class (in the reproduce code "Test") which is basically a container for some attributes. Some of the attributes are the results of expressions which I only want to evaluate when the attribute is accessed for the first time. The __get() function seems perfect for this. One attribute is "repository" - its value should be the result of an expression, concatenated with a slash character and another attribute ("name"), if "name" is not null. When "name" is not null, the first time "repository" is accessed, __get() returns the result of the expression, without anything concatenated. The second time "repository" is accessed, __get() returns just a slash character and "name", without the result of the expression. Reproduce code: --------------- http://cgi.sfu.ca/~jdbates/tmp/php/200811130/test.phps Expected result: ---------------- ket% php test.php string(9) "some expr/name" string(4) "some expr/name" ket% Actual result: -------------- ket% php test.php string(9) "some expr" string(4) "/name" ket% ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46570&edit=1
