Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13137 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45535 invoked by uid 1010); 4 Oct 2004 13:09:39 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 45415 invoked from network); 4 Oct 2004 13:09:38 -0000 Received: from unknown (HELO mproxy.gmail.com) (216.239.56.243) by pb1.pair.com with SMTP; 4 Oct 2004 13:09:38 -0000 Received: by mproxy.gmail.com with SMTP id w67so357980cwb for ; Mon, 04 Oct 2004 06:09:37 -0700 (PDT) Received: by 10.11.119.54 with SMTP id r54mr1245237cwc; Mon, 04 Oct 2004 06:09:37 -0700 (PDT) Received: by 10.11.117.13 with HTTP; Mon, 4 Oct 2004 06:09:37 -0700 (PDT) Message-ID: <4e89b426041004060966b3bdbe@mail.gmail.com> Date: Mon, 4 Oct 2004 14:09:37 +0100 Reply-To: Wez Furlong To: Christian Schneider Cc: Marcus Bointon , PHP internals In-Reply-To: <4161435C.8010108@cschneid.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <4e89b426041004051225c86945@mail.gmail.com> <4161435C.8010108@cschneid.com> Subject: Re: [PHP-DEV] Static call detection From: kingwez@gmail.com (Wez Furlong) I was asked off-list by someone else why I thought it was wrong, it turns out that I wasn't as clear as I could have been, so I'm going to follow up here and then withdraw (because I don't consider it an internals matter). It *is* ok to have a static method and call it either statically or not, provided that the method still behave statically (eg: the same) in both contexts. It is *not* ok to have a static method try and work like a non static method. In PHP 5, declaring a static method will prevent $this from being initialized. static means static. Take this as a hint that what you're trying to do it wrong :-) If you want to hack around the guts and do unsupported stuff like this, be prepared for your code to break in future versions of PHP. *cough* gallery assigning to $this *cough* --Wez. On Mon, 04 Oct 2004 14:34:36 +0200, Christian Schneider wrote: > Wez Furlong wrote: > > If a method is static, you should only ever call it statically. > > Doing any other tricks is just plain wrong. > > I dare to disagree. For tool functions it often makes sense to make them > statically callable while you still might want to use them in an object > instance context respecting the instance's state. It may seem a bit > hacky but I like PHP for being dynamic enough to allow this. > > Different people use different styles and I wouldn't say "Using > exceptions is just plain wrong" even though I don't like them ;-) > > > If you still want to know the answer, ask the question on the correct > > list; what you've asked has nothing to do with hacking on the > > internals of PHP in C. > > He is asking for a mechanism to properly determine the static/non-static > status of a call and I assume he also suggests to add such a mechanism > in case it doesn't exist so I think your answer should be less hostile > as it concerns internals IMHO.