#30002 [Opn->Asn]: Undefined property notice appear when __get method access $this->OtherProperty

From: Date: Sun, 28 Nov 2004 15:57:02 +0000
Subject: #30002 [Opn->Asn]: Undefined property notice appear when __get method access $this->OtherProperty
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-69563@lists.php.net to get a copy of this message
ID: 30002 Updated by: tony2001@php.net Reported By: orlum at mail dot ru -Status: Open +Status: Assigned Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5.0.1 -Assigned To: Andi +Assigned To: andi Previous Comments: ------------------------------------------------------------------------ [2004-09-06 21:46:32] helly@php.net Interesting thing: 1) It should happen at all because using $this->B should result in an implicitly declared proeprty. 2) It is expected behavior because __get/__set have a simple recursion protection which disables __get/__set during __get/__set calls. ------------------------------------------------------------------------ [2004-09-06 18:51:46] orlum at mail dot ru Description: ------------ When __get method accesses other property in some class, expected call to __get method not occurs, undefined property notice appears and null value of property returns. Reproduce code: --------------- <?PHP class A { public function __get($property) { echo "__get()\n"; if ($property == "B") return 1; elseif ($property == "C") return $this->B; } } error_reporting(E_ALL); $a = new A(); echo "B={$a->B}\n"; echo "C={$a->C}\n"; ?> Expected result: ---------------- __get() B=1 __get() __get() C=1 Actual result: -------------- __get() B=1 __get() Notice: Undefined property: A::$B in PHPDocument1 on line 12 C= ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30002&edit=1

« previous php.bugs (#69563) next »