Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8000 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98588 invoked by uid 1010); 19 Feb 2004 15:26:51 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 98564 invoked from network); 19 Feb 2004 15:26:51 -0000 Received: from unknown (HELO shiva.mind.de) (212.42.230.204) by pb1.pair.com with SMTP; 19 Feb 2004 15:26:51 -0000 Received: from [192.168.1.105] (p508EB5F8.dip.t-dialin.net [80.142.181.248]) by shiva.mind.de (Postfix) with ESMTP id DBD3297B64; Thu, 19 Feb 2004 16:26:39 +0100 (CET) Date: Thu, 19 Feb 2004 16:24:55 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <49748001390.20040219162455@marcus-boerger.de> To: Hans Lellelid Cc: Timm Friebe , PHP Internals In-Reply-To: <4034D2ED.5010605@velum.net> 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> <4034D2ED.5010605@velum.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Re: Static weirdness.. From: helly@php.net (Marcus Boerger) Hello Hans, Thursday, February 19, 2004, 4:14:53 PM, you wrote: > 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. I hope nobody wants such strange things. Calling a static method from an instance is just one of the ways to get to the class of that method. -- Best regards, Marcus mailto:helly@php.net