Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7967 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47383 invoked by uid 1010); 18 Feb 2004 17:40:09 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 47346 invoked from network); 18 Feb 2004 17:40:09 -0000 Received: from unknown (HELO punisher.appliedsec.com) (206.112.71.1) by pb1.pair.com with SMTP; 18 Feb 2004 17:40:09 -0000 Received: from appliedsec.com (localhost.applied.sec [127.0.0.1]) by punisher.appliedsec.com (Postfix) with ESMTP id B36C1E0419; Wed, 18 Feb 2004 12:13:44 -0500 (EST) Message-ID: <4033A373.5020509@appliedsec.com> Date: Wed, 18 Feb 2004 12:40:03 -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: Pierre-Alain Joye Cc: John Coggeshall , George Schlossnagle , 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> In-Reply-To: <20040218183012.2ad1beb3@localhost.localdomain> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Static weirdness.. From: hans@appliedsec.com (Hans Lellelid) Hi - Pierre-Alain Joye wrote: > On Wed, 18 Feb 2004 12:23:04 -0500 > John Coggeshall wrote: > >>class foo { >> static function bar() { >> } >>} >>$a = new foo(); >>$a->bar(); /* Unacceptable and contradictory to the concept of static >>*/ foo::bar(); /* Acceptable */ > > > I have the same problem as George :) I did not understand well your > original post. > > We are talking about the same thing. A notice (error sounds too > drastic here) should be raised if a static method is called from the > instanciated object. > I disagree w/ any sort of error being raised by calling a static method from object context. I think it should be allowed because 1) there is already the stuff in static to disallow any reference to $this, so there is no danger of a static method messing w/ instance variables. (i.e. if you're calling it by accident, you'll probably find out pretty quickly) 2) In some cases it is useful to instantiate an otherwise static class for the sake of passing it to some code that doesn't know the name of the static class. For example in Propel (PHP5 Torque port) the "Peer" classes are static classes that do work on entities -- like inserting them in the database, etc. If I have an array of Entity objects, I might want to get access to the Peer class that handles those entities, so I have: foreach($entities as $ent) { $peer = $ent->getPeer(); // e.g. might be BookPeer $peer->doSelect(new Criteria()); //static: BookPeer::doSelect() } This [taken from Java Torque impl] is particularly useful because the alternative is having to invoke the method using call_user_func() or eval() (yuk!). Hans