Hello! Trying to use ZE2's new features for my framework I fell in trouble with (probably) abnormal behaviour of overloaded class properties which has been declared as "expected" long time ago.
First of all, I do admit this feature has been discussed before, but despite of all that I apologize for bringing this issue back and I'd like you to pay a bit of your attention to the subject. The problem is following: <?php class A { public $pub; private $pri; function __get($name) { echo "__get($name)\n"; return $this; } } $a = new A; echo $a->pub; // no error, but direct access. no __get() call is being made echo $a->pri; // results in Fatal error. no __get() call is being made ?> In neither of two echo'es the call to __get() is being made. Short question: Why is that? Long question: Isn't that clear that when there is a __get() declared in a class, this 'magic' method should be called on ANY access to a class property? Those who want it to behave like it does at the moment, may always emulate desired functionality with Reflection API: function __get($name) { $class = new ReflectionClass(__CLASS__); if($class->getProperty($name)->isPrivate()) trigger_error( ... ); return $this->$name; } ...but, please, give some freedom to those who want it! Let __get()/__set() be called on EVERY attempt to access a property, because the current realization makes Overloading practically USELESS for any serious use, since you don't have a 100% control over accessing to class' properties. Thanks in advance for your time and effort to helping us out with this one. Maxx -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php