Location: PHPKode > scripts > dinamicParams > dinamicparams/dinamicParams.class.php
<?php
	class dinamicParams{
		
		function call($callback, $params = array()) {
		    $fParams = $this->getParameters($callback);		    
		
		    foreach ($params as $arg => $value) {
		        $fParams[$arg] = $value;
		    }
		
		    return call_user_func_array($callback, array_values($fParams));
		}
		
		
		function getParameters($callback) {
		    $reflectionObj = $this->getReflectionObj($callback);
		
		    $params = array();
		
		    foreach ($reflectionObj->getParameters() as $param) {
		
		        if ($param->isOptional())
		            $params[$param->name] = $param->getDefaultValue();
		        else
		            $params[$param->name] = null;
		
		    }
		
		    return $params;
		}
		
		
		function getReflectionObj($callback) {
		    if (is_array($callback))
		        $function = new ReflectionMethod($callback[0], $callback[1]);
		    else
		        $function = new ReflectionFunction($callback);
			
	        return $function;
		}
	}
Return current item: dinamicParams