Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42393 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30256 invoked from network); 29 Dec 2008 05:00:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Dec 2008 05:00:49 -0000 Authentication-Results: pb1.pair.com header.from=david.zuelke@bitextender.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=david.zuelke@bitextender.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain bitextender.com from 80.237.132.12 cause and error) X-PHP-List-Original-Sender: david.zuelke@bitextender.com X-Host-Fingerprint: 80.237.132.12 wp005.webpack.hosteurope.de Received: from [80.237.132.12] ([80.237.132.12:50951] helo=wp005.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/42-18017-A7958594 for ; Mon, 29 Dec 2008 00:00:44 -0500 Received: from dslb-088-064-056-176.pools.arcor-ip.net ([88.64.56.176] helo=[192.168.0.101]); authenticated by wp005.webpack.hosteurope.de running ExIM using esmtpsa (TLSv1:RC4-SHA:128) id 1LHAF5-0003Gr-59; Mon, 29 Dec 2008 06:00:39 +0100 Cc: PHP Internals Message-ID: <1943543F-9AE0-4F90-8417-F39175B19EB6@bitextender.com> To: Lars Strojny , Stanislav Malyshev In-Reply-To: <1230181883.12121.9.camel@localhost> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v930.3) Date: Mon, 29 Dec 2008 06:00:38 +0100 References: <08AA10DA-2704-415C-8A8C-893C89990DC1@bitextender.com> <1230181883.12121.9.camel@localhost> X-Mailer: Apple Mail (2.930.3) X-bounce-key: webpack.hosteurope.de;david.zuelke@bitextender.com;1230526844;1cdc5f36; Subject: Re: [PHP-DEV] __invoke() weirdness From: david.zuelke@bitextender.com (=?ISO-8859-1?Q?David_Z=FClke?=) On 25.12.2008, at 06:11, Lars Strojny wrote: > Hi David, > > Am Dienstag, den 23.12.2008, 17:02 +0100 schrieb David Z=FClke: > [...] >> This gives a fatal "Call to undefined method DateTime::getAtom()" >> $d =3D new DateTime(); >> $d->getAtom =3D Curry::create(array($d, 'format'), DATE_ATOM); >> echo $d->getAtom(); > > This is the same as the following: > > $obj =3D new stdClass(); > $obj->method =3D function() { > return "foo"; > }; > $obj->method(); > > The first "method" is a property, the call to "method" is - well - a > method call. Because PHP separates methods and properties in the class > entry structure - and because we have magic methods like __set, __get > and __call, there is no efficient and logical way how to search for > properties with closure instances when a method is not found. We > discussed that before and decided to let closures go out into the wild > and think about adding a solution for prototype alike inheritance =20 > later. I realize that, but I guess it's pretty inconsistent, as I can do - $func(); - $func->__invoke(); - $obj->func->__invoke(); but not - $obj->func(); That was my point; I'm aware of potential reasons for this behavior =20 (like what Stas pointed out). Sorry for the confusion ;) Is it going to be like this forever? Stas said "there is no way to =20 distinguish". Isn't that a parser issue that should be gone now with =20 the switch to re2c? Wouldn't it be possible to just do a lookup for a =20= property that is an object with __invoke if the method was not found? - David=