ID: 42021 User updated by: o_gangrel at hotmail dot com Reported By: o_gangrel at hotmail dot com Status: Bogus Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 5.2.3 New Comment:
Sou you mean, when I have an instace of the class itself, the method __get() will not called? It not sounds good to mee! And the variable is a PRIVATE variable, and it can't be accessed only becouse the class is the same and the instace isn't. Previous Comments: ------------------------------------------------------------------------ [2007-07-17 22:36:12] [EMAIL PROTECTED] Should have been "restricted" instead of "rejected"... ------------------------------------------------------------------------ [2007-07-17 22:12:43] [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 The visibility modifiers work on a per class basis and is not rejected to the same object. ------------------------------------------------------------------------ [2007-07-17 21:17:22] o_gangrel at hotmail dot com Description: ------------ In a class, if instance this same class inside, the method __get() does not is called. Reproduce code: --------------- class class_test { private $sub_classes = array(); private $foo = "bar"; // Default value public function __construct($n = 0) { for($i = 0; $i < $n; $i++) { $this->sub_classes[] = new class_test(); // New "sub" instaces } if($n > 0) { $this->foo = $n; // Change the default value on main instace } } public function __get($name) { switch($name) { case 'foo': return '__get("foo") = '.$this->foo; // Getting the variable, changing the value break; case 'subs': $subs = '$this->foo = '.$this->foo."\n"; // Value of var on main instace foreach($this->sub_classes as $key => $sub_class) { $subs.= "\$this->sub_classes[$key]->foo = ".$this->sub_classes[$key]->foo."\n"; // The value of variable on each "sub" instace } return $subs; break; } return false; } } $test = new class_test(2); // Create the main instace, with 2 "sub" instaces echo $test->subs; // Show the variables Expected result: ---------------- $this->foo = 2 $this->sub_classes[0]->foo = __get("foo") = bar $this->sub_classes[1]->foo = __get("foo") = bar Actual result: -------------- $this->foo = 2 $this->sub_classes[0]->foo = bar $this->sub_classes[1]->foo = bar ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42021&edit=1