Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.2 | Fix "Use of "parent" in callables is deprecated" notice #1169

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions library/Mockery/Mock.php
Expand Up @@ -614,7 +614,7 @@ public function mockery_getMockableProperties()
public function __isset($name)
{
if (false === stripos($name, '_mockery_') && get_parent_class($this) && method_exists(get_parent_class($this), '__isset')) {
return call_user_func('parent::__isset', $name);
return call_user_func(get_parent_class($this) . '::__isset', $name);
}

return false;
Expand All @@ -637,9 +637,9 @@ public function mockery_getExpectations()
public function mockery_callSubjectMethod($name, array $args)
{
if (!method_exists($this, $name) && get_parent_class($this) && method_exists(get_parent_class($this), '__call')) {
return call_user_func('parent::__call', $name, $args);
return call_user_func(get_parent_class($this) . '::__call', $name, $args);
}
return call_user_func_array('parent::' . $name, $args);
return call_user_func_array(get_parent_class($this) . '::' . $name, $args);
}

/**
Expand Down Expand Up @@ -858,7 +858,7 @@ protected function _mockery_handleMethodCall($method, array $args)
// noop - there is no hasPrototype method
}

return call_user_func_array("parent::$method", $args);
return call_user_func_array(get_parent_class($this) . '::' . $method, $args);
}

$handler = $this->_mockery_findExpectedMethodHandler($method);
Expand All @@ -877,18 +877,18 @@ protected function _mockery_handleMethodCall($method, array $args)
(method_exists($this->_mockery_partial, $method) || method_exists($this->_mockery_partial, '__call'))
) {
return call_user_func_array(array($this->_mockery_partial, $method), $args);
} elseif ($this->_mockery_deferMissing && is_callable("parent::$method")
} elseif ($this->_mockery_deferMissing && is_callable(get_parent_class($this) . '::' . $method)
&& (!$this->hasMethodOverloadingInParentClass() || (get_parent_class($this) && method_exists(get_parent_class($this), $method)))) {
return call_user_func_array("parent::$method", $args);
return call_user_func_array(get_parent_class($this) . '::' . $method, $args);
} elseif ($this->_mockery_deferMissing && get_parent_class($this) && method_exists(get_parent_class($this), '__call')) {
return call_user_func('parent::__call', $method, $args);
return call_user_func(get_parent_class($this) . '::__call', $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() || (!is_null($this->_mockery_partial) && method_exists($this->_mockery_partial, $method)) || is_callable("parent::$method")) {
if (\Mockery::getConfiguration()->mockingNonExistentMethodsAllowed() || (!is_null($this->_mockery_partial) && method_exists($this->_mockery_partial, $method)) || is_callable(get_parent_class($this) . '::' . $method)) {
if ($this->_mockery_defaultReturnValue instanceof \Mockery\Undefined) {
return call_user_func_array(array($this->_mockery_defaultReturnValue, $method), $args);
} elseif (null === $this->_mockery_defaultReturnValue) {
Expand Down Expand Up @@ -936,7 +936,7 @@ protected function mockery_getMethods()
private function hasMethodOverloadingInParentClass()
{
// if there's __call any name would be callable
return is_callable('parent::aFunctionNameThatNoOneWouldEverUseInRealLife12345');
return is_callable(get_parent_class($this) . '::aFunctionNameThatNoOneWouldEverUseInRealLife12345');
}

/**
Expand Down