protected function _mockery_handleMethodCall($method, array $args)
{
$this->_mockery_getReceivedMethodCalls()->push(new \Mockery\MethodCall($method, $args));
$rm = $this->mockery_getMethod($method);
if ($rm && $rm->isProtected() && !$this->_mockery_allowMockingProtectedMethods) {
if ($rm->isAbstract()) {
return;
}
try {
$prototype = $rm->getPrototype();
if ($prototype->isAbstract()) {
return;
}
} catch (\ReflectionException $re) {
// noop - there is no hasPrototype method
}
return call_user_func_array("parent::{$method}", $args);
}
if (isset($this->_mockery_expectations[$method]) && !$this->_mockery_disableExpectationMatching) {
$handler = $this->_mockery_expectations[$method];
try {
return $handler->call($args);
} catch (\Mockery\Exception\NoMatchingExpectationException $e) {
if (!$this->_mockery_ignoreMissing && !$this->_mockery_deferMissing) {
throw $e;
}
}
}
if (!is_null($this->_mockery_partial) && method_exists($this->_mockery_partial, $method)) {
return call_user_func_array(array($this->_mockery_partial, $method), $args);
} elseif ($this->_mockery_deferMissing && is_callable("parent::{$method}") && (!$this->hasMethodOverloadingInParentClass() || method_exists(get_parent_class($this), $method))) {
return call_user_func_array("parent::{$method}", $args);
} elseif ($method == '__toString') {
// __toString is special because we force its addition to the class API regardless of the
// original implementation. Thus, we should always return a string rather than honor
// _mockery_ignoreMissing and break the API with an error.
return sprintf("%s#%s", __CLASS__, spl_object_hash($this));
} elseif ($this->_mockery_ignoreMissing) {
if (\Mockery::getConfiguration()->mockingNonExistentMethodsAllowed() || (method_exists($this->_mockery_partial, $method) || is_callable("parent::{$method}"))) {
if ($this->_mockery_defaultReturnValue instanceof \Mockery\Undefined) {
return call_user_func_array(array($this->_mockery_defaultReturnValue, $method), $args);
} elseif (null === $this->_mockery_defaultReturnValue) {
return $this->mockery_returnValueForMethod($method);
} else {
return $this->_mockery_defaultReturnValue;
}
}
}
$message = 'Method ' . __CLASS__ . '::' . $method . '() does not exist on this mock object';
if (!is_null($rm)) {
$message = 'Received ' . __CLASS__ . '::' . $method . '(), but no expectations were specified';
}
throw new \BadMethodCallException($message);
}