ID:               34893
 Updated by:       [EMAIL PROTECTED]
 Reported By:      kai at meder dot info
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: WinXP
 PHP Version:      5.1.0RC1
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[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

Reply via email to