Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47696 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64838 invoked from network); 31 Mar 2010 14:37:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2010 14:37:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=mathieu.suen@easyflirt.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=mathieu.suen@easyflirt.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain easyflirt.com designates 91.199.255.56 as permitted sender) X-PHP-List-Original-Sender: mathieu.suen@easyflirt.com X-Host-Fingerprint: 91.199.255.56 python-06.easyrencontre.com Linux 2.6 Received: from [91.199.255.56] ([91.199.255.56:44520] helo=mail.easyflirt.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/16-53378-F0E53BB4 for ; Wed, 31 Mar 2010 09:37:04 -0500 Received: from [192.168.0.51] (office.easyrencontre.com [78.155.152.6]) by mail.easyflirt.com (Postfix) with ESMTPSA id 766686374D2; Wed, 31 Mar 2010 16:37:00 +0200 (CEST) Message-ID: <4BB35E0B.4000104@easyflirt.com> Date: Wed, 31 Mar 2010 16:36:59 +0200 User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Auke van Slooten CC: internals@lists.php.net, Stanislav Malyshev References: <4BA0DF61.1010907@easyflirt.com> <4BA1DB19.1080608@easyflirt.com> <660eb66f1003180224g5662ba1dtb123c3ee88a3a3e5@mail.gmail.com> <4BA25919.8090805@easyflirt.com> <4BA37E11.9080403@gmail.com> <4BA7C9CF.1000008@zend.com> <4BABF123.4050102@gmail.com> <4BABF675.4010006@zend.com> <4BAC005C.5020404@zend.com> <4BAC7B1C.8000704@easyflirt.com> <4BACF5E7.3050205@zend.com> <4BAD1AF7.8030106@muze.nl> In-Reply-To: <4BAD1AF7.8030106@muze.nl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Assign array with __get From: mathieu.suen@easyflirt.com ("mathieu.suen") Auke van Slooten wrote: > Stanislav Malyshev wrote: >> Hi! >> >>> IMHO __get is not consistent at the first place. >>> on possible example: >> >> It is perfectly consistent. You just need to read what it actually does: >> http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members >> >> instead of imagining what it could do. > > Hi, > > not the same issue, but slightly related, __call() seems to me a bit > inconsistent with __get(). I'm not sure if this is the right thread to > ask this in, if not, I'll be happy to take this somewhere else :) > > __get is called when accessing any inaccessible property, either when > not set or when it is private/protected. But __call() only gets called > when the method is not set, not for private methods. In that case you > get a Fatal error. e.g: > > > class foo { > protected $foo = 'bar'; > > function __get($name) { > return 'getting '.$name."\n"; > } > > private function bar() { > echo 'private bar'; > } > > function __call($name, $params) { > echo 'calling '.$name."\n"; > } > } > > $foo = new foo(); > > echo $foo->foo; > > $foo->bar(); > ?> > > Results in: > > getting foo > > Fatal error: Call to private method foo::bar() from context '' in > /home/auke/public_html/test/get.php on line 23 > > I wouldn't mind this if this is how it supposed to work, but the > documentation uses the same terminology for __get and __call: > > "__get() is utilized for reading data from inaccessible properties." > > and > > "__call() is triggered when invoking inaccessible methods in an object > context." > > In addition the page > http://www.php.net/manual/en/language.oop5.visibility.php > > goes into some detail about when methods are visible and when not, > making no distinction between methods and properties in regard to > visibility, and this page is specifically linked from the page about > overloading, as explaining when __call() should be called: > > "The overloading methods are invoked when interacting with properties > or methods that have not been declared or are not visible in the > current scope. The rest of this section will use the terms > "inaccessible properties" and "inaccessible methods" to refer to this > combination of declaration and visibility. " > > So it seems to me that the above code should not have produced a fatal > error if the documentation is right... or am I misreading something? > > regards, > Auke van Slooten > Muze > IMHO it worth a new thread -- Mathieu Suen