diff --git a/src/Framework/MockObject/MockBuilder.php b/src/Framework/MockObject/MockBuilder.php index d8cd0f4397a..09015053b12 100644 --- a/src/Framework/MockObject/MockBuilder.php +++ b/src/Framework/MockObject/MockBuilder.php @@ -182,21 +182,22 @@ public function setMethods(array $methods = null): self * Specifies the subset of methods to mock, requiring each to exist in the class * * @param string[] $methods + * + * @throws RuntimeException */ public function setRealMethods(array $methods): self { - if ($methods) { - $reflection = new \ReflectionClass($this->type); - - foreach ($methods as $method) { - if (!$reflection->hasMethod($method)) { - throw new RuntimeException( - \sprintf( - 'Trying to set mock method "%s" which cannot be configured because it does not exist', - $method - ) - ); - } + $reflection = new \ReflectionClass($this->type); + + foreach ($methods as $method) { + if (!$reflection->hasMethod($method)) { + throw new RuntimeException( + \sprintf( + 'Trying to set mock method "%s", but it does not exist in class "%s"', + $method, + $this->type + ) + ); } }