ID: 34893 User updated by: kai at meder dot info Reported By: kai at meder dot info -Status: Bogus +Status: Open Bug Type: Scripting Engine problem Operating System: WinXP PHP Version: 5.1.0RC1 New Comment:
in php5.1 all betas and RC1 __get and __set are ALSO called when trying to access protected/private (invisible) properties. btw, the manual describes php5, not php5.1 which is in beta/rc-stadium ... so please forward this *bug* to the overload-developers! Previous Comments: ------------------------------------------------------------------------ [2005-10-19 15:47:56] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Do you even read documentation? Getters and Setters can only be used to access properties that are not declared in the class. ------------------------------------------------------------------------ [2005-10-19 12:53:22] kai at meder dot info do you even read the bug-reports ? by trying to set a private-property __get/__set are triggered in php5.1 (yes, it already works!) but there is a serious problem if using __get AND __set together in a chain! ------------------------------------------------------------------------ [2005-10-19 00:43:21] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php $a->p = $b; is the problem line, you are trying to access a private property from outside the object, this is disallowed. ------------------------------------------------------------------------ [2005-10-17 16:58:27] kai at meder dot info Description: ------------ chaining of objects using __get() works like a charm, however if using chaining and using __set() at the end of the chain to set a property, php fails reporting: "Fatal error: Cannot access private property A::$p in <file> on line <line>" please keep in mind that i'm using php5.1 (RC1), chaining should work in this version, doesn't it? posted reproduce code from http://www.sitepoint.com/forums/showthread.php?p=2230679#post2230679 Reproduce code: --------------- class A { private $p; function __get($name){ return $this->$name; } function __set($name, $value) { $this->$name = $value; } } class B { private $t; function __get($name){ return $this->$name; } function __set($name, $value) { $this->$name = $value; } } $a = new A; $b = new B; $a->p = $b; $b->t = "foo"; echo $a->p->t; $a->p->t = "bar"; echo $a->p->t; Expected result: ---------------- foobar Actual result: -------------- foo Fatal error: Cannot access private property A::$p in... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34893&edit=1