I need to call a method that returns reference using call_user_func or something like that. My problem is that call_user_func does not return a reference, neither does the ReflectionMethod::invokeArgs() method.
I'll most likely be able to do it with eval() but I was wondering if there is some other way?
Problem with call_user_func and references
Moderator: General Moderators
-
Pulni4kiya
- Forum Commoner
- Posts: 35
- Joined: Tue Apr 14, 2009 6:20 am
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Problem with call_user_func and references
Unfortunately not. This is one of my gripes with PHP. func_get_args() does not return references neither. Very frustrating if you're working with by-reference methods.
-
Pulni4kiya
- Forum Commoner
- Posts: 35
- Joined: Tue Apr 14, 2009 6:20 am
Re: Problem with call_user_func and references
Yeah, I needed func_get_args with references, too.
It's very sad that PHP has these reference problems.
Guess, I'll do it with eval() then...not that I like it much...
Thanks anyway!
It's very sad that PHP has these reference problems.
Guess, I'll do it with eval() then...not that I like it much...
Thanks anyway!
Re: Problem with call_user_func and references
could you provide me an example pls. i don't understand exactly what you mean. thanks.Pulni4kiya wrote:I need to call a method that returns reference using call_user_func or something like that.
-
Pulni4kiya
- Forum Commoner
- Posts: 35
- Joined: Tue Apr 14, 2009 6:20 am
Re: Problem with call_user_func and references
Something like this:
class A {
protected function &a($b1,$b2,$b3) { ... }
}
class B extends A {
protected function &a($b1,$b2,$b3) { ... }
public function &call($methodName, array $args) {
//I'm here and I want to call parent::$methodName($args); and return the reference it returned.
}
}
class A {
protected function &a($b1,$b2,$b3) { ... }
}
class B extends A {
protected function &a($b1,$b2,$b3) { ... }
public function &call($methodName, array $args) {
//I'm here and I want to call parent::$methodName($args); and return the reference it returned.
}
}