Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40185 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89041 invoked from network); 31 Aug 2008 10:50:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Aug 2008 10:50:52 -0000 Authentication-Results: pb1.pair.com header.from=dafneves@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=dafneves@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.166.177 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: dafneves@gmail.com X-Host-Fingerprint: 64.233.166.177 py-out-1112.google.com Received: from [64.233.166.177] ([64.233.166.177:62088] helo=py-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0E/B9-27196-B877AB84 for ; Sun, 31 Aug 2008 06:50:51 -0400 Received: by py-out-1112.google.com with SMTP id a25so835987pyi.16 for ; Sun, 31 Aug 2008 03:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=YUZegEx6xsTbGa64H3nkGLYFl2qyaZX8jc8IVzUiems=; b=nkKce+5fVySteByO/F1QQWrkEnZ5nvzw3DRZxtLrHwQX/6qXiD6yWpzb6co+4Bh0H+ ZNJOxRZpnTev80t5LTsuwRqnutSIGaTW/jGswCtve+qkXzD3FDqVwDQBA+NT+XEa7H93 NZdi9GQXyzvBhRkQCqm7IygCw1+g8GLTmvcNQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=PGT1M5lwv+urFVEnetEHPH45kA0oXfVWnG2NSuJRNuz8lQVK06FD5QqOhBhkC+3c53 5rjuOA0Eo1Mw0Xeap3Ntkig0Rl4vNhn7rm1Pp/Y0cbg9/7CGa1DInBD/rtN+eiMocfiu wlph1YPO8SOj54tIp1va5Exc32A0zcMN1nKMw= Received: by 10.65.240.13 with SMTP id s13mr10001453qbr.91.1220179849050; Sun, 31 Aug 2008 03:50:49 -0700 (PDT) Received: by 10.65.242.4 with HTTP; Sun, 31 Aug 2008 03:50:48 -0700 (PDT) Message-ID: <87ae45950808310350n389f73f7qb710e05fbf5655aa@mail.gmail.com> Date: Sun, 31 Aug 2008 11:50:48 +0100 To: "Marcus Boerger" Cc: "Rasmus Lerdorf" , "=?ISO-8859-1?Q?Cristian_Rodr=EDguez?=" , internals@lists.php.net In-Reply-To: <607814897.20080831120322@marcus-boerger.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <87ae45950808301302o24f164daj4377a360f3ed1a2c@mail.gmail.com> <48B9B3F8.2060409@suse.de> <48B9B55A.6050707@lerdorf.com> <87ae45950808301550n392cee6ft245c7be188b30e7b@mail.gmail.com> <607814897.20080831120322@marcus-boerger.de> Subject: Re: [PHP-DEV] __call() magic method From: dafneves@gmail.com ("Diogo Neves") On Sun, Aug 31, 2008 at 11:03 AM, Marcus Boerger wrote: > Hello Diogo, > > Sunday, August 31, 2008, 12:50:15 AM, you wrote: > >> Exactly... > >> Is that normal workings or more like a bugie one? > >> On Sat, Aug 30, 2008 at 10:02 PM, Rasmus Lerdorf wr= ote: >>> Cristian Rodr=EDguez wrote: >>>> >>>> Diogo Neves escribi=F3: >>>>> >>>>> Hi all, >>>>> >>>>> I'm emailling to ask why __call isn't called when you call a private >>>>> method from outside of function... >>>> >>>> Please provide example code ;-) >>> >>> He means this: >>> >>> class foo { >>> private function bar() { } >>> function __call($f,$a) { >>> echo "called $f"; >>> } >>> } >>> $a =3D new foo; >>> $a->bar(); >>> > > In the above code you clearly try to call a private method. As Mike Lively before point to me __get, and after i tried __set, works diferently as u can see: $name =3D $value; } public function __get( $name ) { =09return $this->$name; } } $obj =3D new foo; $obj->a =3D 'b'; echo( $obj->a ); ?> My problem was that i only had work with __get and expected same behavior for __call :) There is > nothing more to say. In the following case it coul dbe a bit different: > > class foo { > private function test() { > echo __METHOD__ . "\n"; > } > } > class bar extends foo { > function __call($name, $args) { > echo __METHOD__ . "($name)\n"; > } > } > $obj =3D new foo; > $obj->test(); > ?> > > This is different because we call into an object of type bar. Now in scop= e > bar we do not know anything about foo::test. a ); } } class bar extends foo { private $a =3D 'b'; public function test2() { echo( $this->a ); } } $obj =3D new bar; $obj->test(); $obj->test2(); ?> Now i understood what u mean by 'bar' scope... :S I'm in need of a good scope article, some one know a good one? That said we should probably > allow __call there rather than the error. And it is easy enought o fix as > we know that in bar we have only inherited foo::test. > > If we move __call into foo it is the other way around then again. This is > because we will call into the object and start method resolution at scope > bar. As that does not know anything about test, we will use the inherited > method call to dynamically handle the call. However, that means we are in > scope foo where we do know about test and hence should issue the error. > But we will have a harder time issuing that error. As inside the engine w= e > actually never go down to scope foo and instead simply use the inherited > __call. > > So yes, this can be seen as a bug and part of it can easily be fixed. But > I do not see an easy way to fix it 100% according to inheritance rules. > > Best regards, > Marcus > --=20 Thanks for your attention, Diogo Neves Web Developer @ SAPO.pt by PrimeIT.pt