admin wrote: > Jochem Maas wrote: >> another solution for the OP might be (although I think it goes against >> all >> design principles): >> >> class A { >> function foo() { >> echo "achoo\n"; >> } >> } >> >> class B extends A { >> function foo() { >> echo "cough\n"; >> } >> function __call($meth, $args) { >> $func = array(parent, strtolower(str_replace("parent","", $meth))); >> if (is_callable($func)) >> return call_user_func_array($func, $args); >> } >> } >> >> $b = new B; >> $b->foo(); >> $b->parentFoo(); >> > > Barring the s/parent/get_parent_class/ the idea is really really cute, > thanks. Beautiful. Heck, maybe I'll even hack the code to do it like > that... after some grace period. sure it might be a neat little hack - __call() can be used for alsorts of wonderful madness but do note it can become a maintainance and/or documentation nightmare ... not to mention that it doesn't work with code completion in any editor I know. and having read what you wrote about Propel/Symphony I still don't get what the problem is that your trying to solve ... although I suspect that your probably suffering from a lack of late static binding (which, if we had it, could be used to minimize alot of repetitive boiler plate code in [for instance] 'data object' classes that extend a common base ... then again I may be wrong :-) [Do not get me started on LSB - I've been moaning about it since 5.0RC3] > P.S.: I thought calling array('classname', 'method') only worked for > static methods? It turns out there's an implied $this being passed around? the 'callback' type has a number of forms: 'myFunc' array('className', 'myMeth') array(self, 'myMeth') array(parent, 'myMeth') array($object, 'myMeth') self and parent adhere to the same 'context' rules when used in call_user_func*() as when you use them directly - whether $this is present within the scope of the called method is essentially down to whether the method being called is defined as static or not. AFAIK call_user_func*() respects PPP modifiers and works transparently with regard to access to the relevant object variable ($this) > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php