Php ReflectionMethod
===

I am trying to do some function that will find passed variables and find required arguments on a given method from a given class and try to match them so you dont have to pass variables on specific order. The function works good when i pass all vars but when i miss some var to pas and expect method to give default one I recive error

> Fatal error: Uncaught exception 'ReflectionException' with message 'Parameter is not optional' in /share/HDA_DATA/Web/framework/framework.php:45 Stack trace: #0 /share/HDA_DATA/Web/framework/framework.php(45): ReflectionParameter->getDefaultValue() #1 /share/HDA_DATA/Web/framework/framework.php(59): passValues() #2 {main} thrown in /share/HDA_DATA/Web/framework/framework.php on line 45

Here i have my code and i call it like

> www.domainname.com/index.php?class=person&method=identification&surname=Somesurname&somestrangevar=justtest

    class foo 
    {
    	public function bar($one, $two, $stupid, $somethingelse)
    	{
    		echo $one.$two.$stupid.$somethingelse;
    	}
    	public function zar($one,$somethingelse)
    	{
    		echo $one.$somethingelse;
    	}
    }
    
    class person 
    {
    	public function identification($name = 'Smith', $surname)
    	{
    		echo "Name: ".$name."<br/>";
    		echo "Surname: ".$surname."<br/>";
    	}
    }
    
    $method = new ReflectionMethod($_GET['class'], $_GET['method']);
    $num = $method->getParameters();
    
    function passValues()
    {
    	global $method;
    	$arguments = array();
    	foreach($method->getParameters() as $value)
    	{
    		if(isset($_GET[$value->name]) && $_GET[$value->name] !="")
    		{
    			$arguments[$value->name] = $_GET[$value->name];
    			
    		}
    		else
    		{
    			if($value->isDefaultValueAvailable())
			{
				$arguments[$value->name] = $value->getDefaultValue();
			}
			else
			{
				echo "Please give value to parameter '".$value->name."'.";
				return 0;
			}
    		}
    	}
    	
    	$myFoo = new $_GET['class'];
    
    	call_user_func_array(array($myFoo, $_GET['method']) , $arguments);
    }
    passValues();

Using PHP version 5.3.9