Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47648 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8997 invoked from network); 26 Mar 2010 20:37:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Mar 2010 20:37:16 -0000 X-Host-Fingerprint: 82.95.143.127 helikon.muze.nl Received: from [82.95.143.127] ([82.95.143.127:3333] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3C/21-00160-9FA1DAB4 for ; Fri, 26 Mar 2010 15:37:14 -0500 To: internals@lists.php.net,Stanislav Malyshev Message-ID: <4BAD1AF7.8030106@muze.nl> Date: Fri, 26 Mar 2010 21:37:11 +0100 User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 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> In-Reply-To: <4BACF5E7.3050205@zend.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 82.95.143.127 Subject: Re: [PHP-DEV] Assign array with __get From: auke@muze.nl (Auke van Slooten) 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: 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