Re: Static call detection

From: Date: Mon, 04 Oct 2004 16:57:37 +0000
Subject: Re: Static call detection
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-13145@lists.php.net to get a copy of this message
Marcus Bointon wrote:
on 4/10/04 13:34, Christian Schneider at cschneid@cschneid.com wrote:
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.
In this case I was writing a 'delete' method that would either delete the current object's database record, or if passed an ID and called statically (hence the need to detect it), the record corresponding to that id.
What about: class A { function delete($id = null) {
     if(is_null($id)) {
$id = $this->id;
     }
} }

« previous php.internals (#13145) next »