From f09b0804979be2e679db4d1273306493f014f764 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 15 Mar 2022 08:18:58 +0100 Subject: [PATCH] PHP 8.2: fix "Use of "parent" in callables is deprecated" notice 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 --- library/Mockery/Mock.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/library/Mockery/Mock.php b/library/Mockery/Mock.php index e62116f98..95bb5f399 100644 --- a/library/Mockery/Mock.php +++ b/library/Mockery/Mock.php @@ -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; @@ -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); } /** @@ -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); @@ -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) { @@ -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'); } /**