tags:

views:

24

answers:

2

Lets say I have a class like:

class SomeClass{
    function someAction($param1,$param2){}
}

Is there any way to get analyzing data like array('param1','param2') without actual execution of method? Preferably without php extensions or prior code analysis (fopen...)

+1  A: 

I think you can use the Reflection class to get info about method(s) and params.

Sarfraz
A: 

Great, thank you all, solved it with something like

$oRuleContainer = new cRuleContainer();
$rContainer = new ReflectionClass('cRuleContainer');

$rMethod = $rContainer->getMethod($aRule['method']);
$aArgs = $rMethod->getParameters();

if($aArgs){
    foreach($aArgs as $refArgument){
        $arrPassedArgData[$refArgument->name]=$_POST[$refArgument->name];
    }
}

if(call_user_func_array(array($oRuleContainer,$aRule['method']),$arrPassedArgData)){
//success
}

More details at http://kurapov.name/rus/technology/web/php/reflection_php_brms/

Artjom Kurapov