Hi, __get() makes more sense to me, and maybe was where | got the ideia because | never used __call() before but i add used __get() :( Maybe the php folks change its behavior in future...
It's worthy of a bug report ( I ask because i'm not very involved in php community ) Thanks, On Sun, Aug 31, 2008 at 1:35 AM, Mike Lively <[EMAIL PROTECTED]> wrote: > Antony, > I don't at all disagree about the inappropriateness of this not triggering > an error but I did want to point out that this behavior is not consistent > with how __get() works. It seems like they should all behave similarly when > dealing with overriding methods or properties of different access levels. > > +++ Attempting to access a private property > [EMAIL PROTECTED]:~$ php -r 'class A { private $a; } $a = new A; $a->a;' > Fatal error: Cannot access private property A::$a in Command line code on > line 1 > > +++ Attempting to access a private property when __get() is defined > [EMAIL PROTECTED]:~$ php -r 'class A { private $a; public function > __get($var) { echo $var, "\n"; } } $a = new A; $a->a;' > a > > +++ Attempting to access a private method > [EMAIL PROTECTED]:~$ php -r 'class A { private function a() {} } $a = new > A; $a->a();' > Fatal error: Call to private A::a() from invalid context in Command line > code on line 1 > > ++ Attempting to access a private method when __call is defined > [EMAIL PROTECTED]:~$ php -r 'class A { private function a() {} public > function __call($method, $parms) { echo $method, "\n"; } } $a = new A; > $a->a();' > > Fatal error: Call to private A::a() from invalid context in Command line > code on line 1 > > On Sat, Aug 30, 2008 at 4:04 PM, Antony Dovgal <[EMAIL PROTECTED]> wrote: >> >> On 31.08.2008 02:50, Diogo Neves wrote: >>> >>> Exactly... >>> >>> Is that normal workings or more like a bugie one? >> >> Definitely not a bug. >> >> I believe the reason is that if you enable __call() in this case, you'd >> have different behavior depending on the calling scope, i.e. complete mess. >> Also there would be no way to know you're calling a method you're not >> supposed to call (unless you trigger an error yourself). >> >> -- >> Wbr, Antony Dovgal >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > -- Thanks for your attention, Diogo Neves Web Developer @ SAPO.pt by PrimeIT.pt -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php