ID: 38122
User updated by: toomuchphp-phpbugs at yahoo dot com
Reported By: toomuchphp-phpbugs at yahoo dot com
Status: Open
-Bug Type: Feature/Change Request
+Bug Type: Class/Object related
-PHP Version: 5.1.4
+PHP Version: 5.2.0RC1
New Comment:
Also occurs in PHP-5.2.0RC1.
Previous Comments:
------------------------------------------------------------------------
[2006-07-17 08:14:27] toomuchphp-phpbugs at yahoo dot com
Description:
------------
Recursive use of __get() results in the misleading error message
"Notice: Undefined property: someClass::$foo in file.php". It appears
at first as though __get() is not being called for some properties and
there is no apparent reason why, when the problem is really accidental
recursion. PHP correctly detects the recursion and aborts __get(), but
the error gives no indication of the recursion problem and it can be
very difficult to figure out why __get() is not being called.
I can provide a fix for zend_object_handlers.c, but it really is just a
60-second change to capture the recursiveness error and output an
alternative error message.
Reproduce code:
---------------
class test {
function __get($var) {
return $this->$var;
}
}
$obj = new test;
echo $obj->foo;
Expected result:
----------------
Warning: Recursive use of __get() while accessing test::$foo; cannot
read property recursive::$foo in <file> on line x
Actual result:
--------------
Notice: Undefined property: test::$foo in <file> on line x
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38122&edit=1