Reputation: 6155
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...)
Upvotes: 0
Views: 255
Reputation: 6155
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/
Upvotes: 0
Reputation: 382666
I think you can use the Reflection class to get info about method(s) and params.
Upvotes: 1