Skip to content

Commit

Permalink
Merge pull request #1068 from GrahamCampbell/fix-method-exists
Browse files Browse the repository at this point in the history
Fixed "TypeError: method_exists(): Argument #1 ($object_or_class) must be of type object|string, bool given"
  • Loading branch information
davedevelopment committed Jun 4, 2020
2 parents f24033d + 2835e31 commit 7ac920d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions library/Mockery/Mock.php
Expand Up @@ -612,7 +612,7 @@ public function mockery_getMockableProperties()

public function __isset($name)
{
if (false === stripos($name, '_mockery_') && method_exists(get_parent_class($this), '__isset')) {
if (false === stripos($name, '_mockery_') && get_parent_class($this) && method_exists(get_parent_class($this), '__isset')) {
return call_user_func('parent::__isset', $name);
}

Expand All @@ -635,7 +635,7 @@ public function mockery_getExpectations()
*/
public function mockery_callSubjectMethod($name, array $args)
{
if (!method_exists($this, $name) && method_exists(get_parent_class($this), '__call')) {
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_array('parent::' . $name, $args);
Expand Down Expand Up @@ -890,9 +890,9 @@ protected function _mockery_handleMethodCall($method, array $args)
) {
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))) {
&& (!$this->hasMethodOverloadingInParentClass() || (get_parent_class($this) && method_exists(get_parent_class($this), $method)))) {
return call_user_func_array("parent::$method", $args);
} elseif ($this->_mockery_deferMissing && method_exists(get_parent_class($this), '__call')) {
} elseif ($this->_mockery_deferMissing && get_parent_class($this) && method_exists(get_parent_class($this), '__call')) {
return call_user_func('parent::__call', $method, $args);
} elseif ($method == '__toString') {
// __toString is special because we force its addition to the class API regardless of the
Expand Down

0 comments on commit 7ac920d

Please sign in to comment.