Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7998 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72878 invoked by uid 1010); 19 Feb 2004 15:14:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 72854 invoked from network); 19 Feb 2004 15:14:53 -0000 Received: from unknown (HELO punisher.appliedsec.com) (206.112.71.1) by pb1.pair.com with SMTP; 19 Feb 2004 15:14:53 -0000 Received: from velum.net (localhost.applied.sec [127.0.0.1]) by punisher.appliedsec.com (Postfix) with ESMTP id C1A88E0448; Thu, 19 Feb 2004 09:48:17 -0500 (EST) Message-ID: <4034D2ED.5010605@velum.net> Date: Thu, 19 Feb 2004 10:14:53 -0500 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030807 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Timm Friebe Cc: PHP Internals References: <1077090830.30573.1.camel@coogle.localdomain> <20040218115421.434ac336@localhost.localdomain> <1077124444.30567.27.camel@coogle.localdomain> <1077124984.31528.1.camel@coogle.localdomain> <20040218183012.2ad1beb3@localhost.localdomain> <4033A373.5020509@appliedsec.com> <1077197514.272.9.camel@localhost> In-Reply-To: <1077197514.272.9.camel@localhost> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Static weirdness.. From: hans@velum.net (Hans Lellelid) Timm Friebe wrote: > On Wed, 2004-02-18 at 18:40, Hans Lellelid wrote: > >>foreach($entities as $ent) { >> $peer = $ent->getPeer(); // e.g. might be BookPeer >> $peer->doSelect(new Criteria()); //static: BookPeer::doSelect() >>} > > > $m= new Reflection_Method($ent->getPeer(), 'doSelect'); > $m->invoke(NULL, new Criteria()); > > /* untested */ > Yeah, I'm sure there's a way to get something like that to work also. I'm not sure that's prefereable to call_user_func(), honestly -- and it doesn't get around the basic problem which is that calling code needs to know whether methods are static. I guess I'm not sure why this is necessary ... As Hartmut & Lukas mention, I don't know why the class consumer *needs* to know that it's static. Clearly internally there should be no possibility of referencing $this. Also in my example the entire class is static -- i.e. all methods are static -- but what about cases where one or two methods in a class are static. Now $a->methodName() will work for most but all of a sudden you have to do $a::staticMethodName() for the static members. What I see as the workaround is creating static methods that aren't marked as static -- e.g. that would address the issue in my example above. I think that's a lot worse than allowing invocation of static methods using instances, however, because I do want developers who read the API docs to know these are static functions. Hans