Re: Multi-Method Dispatch in PHP 5.1?

From: Date: Wed, 21 Apr 2004 07:05:47 +0000
Subject: Re: Multi-Method Dispatch in PHP 5.1?
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-9453@lists.php.net to get a copy of this message
Andrey Hristov wrote: > class foobar { [...] > protected function doSomething_objectFubar($fub) { > $a = func_get_args();var_dump(__METHOD__, $a); > } > > public function doSomething() { > $args = func_get_args(); > $method_name = __FUNCTION__; > foreach ($args as $v) { > $method_name .= "_".gettype($v); > if (FALSE !==($c_name = get_class($v))) { > $method_name .= $c_name; > } > } > if (method_exists($this, $method_name)) { > return call_user_func_array(array($this, $method_name), $args); > } > } > }//class fubar Now I do a <?php class barfoo extends foobar { } $barfoo = new barfoo(); $barfoo->doSomething($barfoo); ?> And it won't work anymore,so I can't extend te class anymore without changing the class foobar.... johannes

« previous php.internals (#9453) next »