Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40178 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91019 invoked from network); 31 Aug 2008 00:35:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Aug 2008 00:35:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=m@digitalsandwich.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=m@digitalsandwich.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain digitalsandwich.com does not designate 209.85.146.183 as permitted sender) X-PHP-List-Original-Sender: m@digitalsandwich.com X-Host-Fingerprint: 209.85.146.183 wa-out-1112.google.com Received: from [209.85.146.183] ([209.85.146.183:51268] helo=wa-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9D/78-27196-857E9B84 for ; Sat, 30 Aug 2008 20:35:38 -0400 Received: by wa-out-1112.google.com with SMTP id v27so880364wah.17 for ; Sat, 30 Aug 2008 17:35:34 -0700 (PDT) Received: by 10.114.154.12 with SMTP id b12mr4056082wae.153.1220142934434; Sat, 30 Aug 2008 17:35:34 -0700 (PDT) Received: by 10.115.17.4 with HTTP; Sat, 30 Aug 2008 17:35:34 -0700 (PDT) Message-ID: <8d7b8c130808301735h76252afme4baabe322355f60@mail.gmail.com> Date: Sat, 30 Aug 2008 17:35:34 -0700 To: "Antony Dovgal" Cc: "Diogo Neves" , internals@lists.php.net In-Reply-To: <48B9D1EC.2080101@daylessday.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_30195_19830402.1220142934423" References: <87ae45950808301302o24f164daj4377a360f3ed1a2c@mail.gmail.com> <48B9B3F8.2060409@suse.de> <48B9B55A.6050707@lerdorf.com> <87ae45950808301550n392cee6ft245c7be188b30e7b@mail.gmail.com> <48B9D1EC.2080101@daylessday.org> Subject: Re: [PHP-DEV] __call() magic method From: m@digitalsandwich.com ("Mike Lively") ------=_Part_30195_19830402.1220142934423 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 mikel@mikel-desktop:~$ 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 mikel@mikel-desktop:~$ 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 mikel@mikel-desktop:~$ 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 mikel@mikel-desktop:~$ 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 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 > > ------=_Part_30195_19830402.1220142934423--