Using parent with call_user_func_array

From: Date: Sat, 03 Sep 2005 19:33:52 +0000
Subject: Using parent with call_user_func_array
Groups: php.general 
Request: Send a blank email to php-general+get-221829@lists.php.net to get a copy of this message
Should these two pieces of code function identically? $aArgs = array('testarg1','testarg2'); call_user_func_array(array('parent','AddNewElement',$aArgs) and parent::AddNewElement('testarg1','testarg2'); I'm havign trouble debugging this, but my app seems to be going into an infinite loop when parent::AddNewElement is called with call_user_func_array. I've found a fairly old bug related to self / parent and call_user_func[_array] , but this is nto the same thing. Though the discussions of this bug do lead me to believe that call_user_func_array should behave as I am expecting it to. Am I missing something? Is this a bug? Is there a workaround? More details about my problem follow Apache2, PHP 5.0.3 I've got a method defined in a class called AddNewElement(). In a sub-class, I'm redefining overloading AddNewElement, and the only thing I want to do is add an argument to the argument list, and then pass it on to the parent::AddNewElement() I can't do these statically, as the number of arguments is flexible (though it's guaranteed to have at least one argument.. <?php ... protected function AddNewElement($sClass) {
       $aArgs = func_get_args();
       array_splice($aArgs,1,0,(array)$this->NextID());
       return call_user_func_array(array('parent','AddNewElement'),$aArgs);
} ... ?> Thanks, Chris

« previous php.general (#221829) next »