From c2dc716dbcf4b55f32077e42b4d780edac8d0a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Mon, 9 Sep 2024 07:28:31 +0200 Subject: [PATCH] Do not use the ternary operator --- src/Framework/Constraint/Callback.php | 10 ++++++---- src/Framework/MockObject/Runtime/Rule/Parameters.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Framework/Constraint/Callback.php b/src/Framework/Constraint/Callback.php index 4ff1c11120..31dce1d2e9 100644 --- a/src/Framework/Constraint/Callback.php +++ b/src/Framework/Constraint/Callback.php @@ -42,7 +42,7 @@ public function toString(): string /** * @psalm-suppress ArgumentTypeCoercion */ - public function hasVariadicParam(): bool + public function isVariadic(): bool { foreach ((new ReflectionFunction($this->callback))->getParameters() as $parameter) { if ($parameter->isVariadic()) { @@ -63,8 +63,10 @@ public function hasVariadicParam(): bool */ protected function matches(mixed $other): bool { - return $this->hasVariadicParam() - ? ($this->callback)(...$other) - : ($this->callback)($other); + if ($this->isVariadic()) { + return ($this->callback)(...$other); + } + + return ($this->callback)($other); } } diff --git a/src/Framework/MockObject/Runtime/Rule/Parameters.php b/src/Framework/MockObject/Runtime/Rule/Parameters.php index 0f7a5977aa..a1f100d08d 100644 --- a/src/Framework/MockObject/Runtime/Rule/Parameters.php +++ b/src/Framework/MockObject/Runtime/Rule/Parameters.php @@ -109,7 +109,7 @@ private function doVerify(): bool } foreach ($this->parameters as $i => $parameter) { - if ($parameter instanceof Callback && $parameter->hasVariadicParam()) { + if ($parameter instanceof Callback && $parameter->isVariadic()) { $other = $this->invocation->parameters(); } else { $other = $this->invocation->parameters()[$i];