note 75047 deleted from language.oop5.overloading by nlopess

From: Date: Sun, 20 May 2007 13:51:33 +0000
Subject: note 75047 deleted from language.oop5.overloading by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126749@lists.php.net to get a copy of this message
Note Submitter: stephen at one2one3 dot com ---- What is the status on using __{get,set,call} statically? I tried to implement a rails style findBy method using __call, but ended up having to make it instance-based when i ran into the issues mentioned by yuggoth23 below: <?php public function __call($methodName, $methodArguments) { if (strpos($methodName, 'findBy') === 0) { $lookupKey = strtolower(substr($methodName, strlen('findBy'))); if ($lookupKey) { $lookupValue = $methodArguments[0]; $fields = isset($methodArguments[1]) ? $methodArguments[1] : '*'; return $this->findBy($lookupKey, $lookupValue, $fields); } } throw new MethodNotFoundException($methodName); } ?> so usage ends up being <?php $user = new User(); $user->findByName('joeyjoejoe'); ?> which sucks enough that its not worth using. I'd also like to access static member variables using __get and that doesn't work either <?php class Duh { function __get($nm) { echo $nm; } } $d = new Duh(); echo $d->blah; echo Duh::blah; echo Duh::blah(); ?> results in: blah Undefined class constant 'blah' Call to undefined method Duh::blah() Making __get a static method didn't seem to have an effect. Anybody have any clean workarounds or know of the priority/possibility of these things getting fixed? There is an existing bug in for this, but it doesn't look like there's been any movement for awhile. http://bugs.php.net/bug.php?id=26739

« previous php.notes (#126749) next »