Skip to content

Commit

Permalink
Do not use the ternary operator
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos authored and sebastianbergmann committed Sep 9, 2024
1 parent 1c004af commit c2dc716
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/Framework/Constraint/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/Framework/MockObject/Runtime/Rule/Parameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit c2dc716

Please sign in to comment.