Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43317 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74180 invoked from network); 11 Mar 2009 21:16:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2009 21:16:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=webmaster@ajeux.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=webmaster@ajeux.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ajeux.com from 74.125.78.27 cause and error) X-PHP-List-Original-Sender: webmaster@ajeux.com X-Host-Fingerprint: 74.125.78.27 ey-out-2122.google.com Received: from [74.125.78.27] ([74.125.78.27:62013] helo=ey-out-2122.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/CD-09289-B1A28B94 for ; Wed, 11 Mar 2009 16:16:12 -0500 Received: by ey-out-2122.google.com with SMTP id d26so32734eyd.59 for ; Wed, 11 Mar 2009 14:16:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.47.16 with SMTP id s16mr3688362web.16.1236806167808; Wed, 11 Mar 2009 14:16:07 -0700 (PDT) Reply-To: olivier@ajeux.com Date: Wed, 11 Mar 2009 22:16:07 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=0016365ee1e049d35e0464de603b Subject: non static function called as static one From: webmaster@ajeux.com (Olivier Doucet) --0016365ee1e049d35e0464de603b Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello, I posted the same topic on the general mailing list, but it appears this can be posted here, as it is open to feedbacks and is about PHP implementation of static functions. I'm wondering if the following behaviour is a bug or a feature. The case is quite complex, so let me explain my point of view. here is the source : test(); //output: "MySecondTest" ?> In this case, $this is MySecondTest, which is relevant as it is the last object context. But to my mind, this code should not work like this. Imagine you are the developer of function MyTest. You want your code to interact with other classes and being bugproof. 'MyTest' class here seems OK: $this is expected to be 'MyTest' because function myfunc() is expected to be called in a non-static context. Programmer of the second function created this bug and this unattended behaviour. Maybe this can be done : 1/ Forbid calling the function in static context (How can I test this ? $this is not NULL there !). 2/ (or/and) Raise an error if a non static function is called as a static one (if E_STRICT is set, strict warning is already raised). 3/ Create two functions with the same name, one static and the other one not. Unfortunately, this can't be done (yet ?). What do you think ? What's your point of view on this ? I want your feedbacks before opening a bug ticket, as it is not strictly a "bug"... --0016365ee1e049d35e0464de603b--