public static function _arguments_match($mockclass, $method, $a, $b)
{
// See if there are any defaults for the given method
if (isset(self::$_defaults[$mockclass][$method])) {
// If so, get them
$defaults = self::$_defaults[$mockclass][$method];
// And merge them with the passed args
$a = $a + $defaults;
$b = $b + $defaults;
}
// If two argument arrays are different lengths, automatic fail
if (count($a) != count($b)) {
return false;
}
// Step through each item
$i = count($a);
while ($i--) {
$u = $a[$i];
$v = $b[$i];
// If the argument in $a is a hamcrest matcher, call match on it. WONTFIX: Can't check if function was passed a hamcrest matcher
if (interface_exists('Hamcrest_Matcher') && ($u instanceof Hamcrest_Matcher || isset($u->__phockito_matcher))) {
// The matcher can either be passed directly, or wrapped in a mock (for type safety reasons)
$matcher = null;
if ($u instanceof Hamcrest_Matcher) {
$matcher = $u;
} elseif (isset($u->__phockito_matcher)) {
$matcher = $u->__phockito_matcher;
}
if ($matcher != null && !$matcher->matches($v)) {
return false;
}
} else {
if (serialize($u) != serialize($v)) {
return false;
}
}
}
return true;
}