Skip to content

Commit

Permalink
PHP 8.2: fix "Use of "parent" in callables is deprecated" notice
Browse files Browse the repository at this point in the history
I've searches the code base to see if I could find all affected callbacks. No guarantee I've found them all though.

Fixes 1168
  • Loading branch information
jrfnl committed Mar 15, 2022
1 parent 472fa8c commit f09b080
Showing 1 changed file with 9 additions and 9 deletions.
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

0 comments on commit f09b080

Please sign in to comment.