diff --git a/src/PendingObjects/TestCall.php b/src/PendingObjects/TestCall.php index f8ada58d..287ca7a9 100644 --- a/src/PendingObjects/TestCall.php +++ b/src/PendingObjects/TestCall.php @@ -81,17 +81,17 @@ final class TestCall /** * Asserts that the test throws the given `$exceptionClass` when called if the given condition is true. * - * @param Closure|bool|int $condition + * @param (callable(): bool)|bool $condition */ public function throwsIf($condition, string $exception, string $exceptionMessage = null): TestCall { $condition = is_callable($condition) ? $condition - : Closure::fromCallable(function () use ($condition): bool { - return (bool) $condition; - }); + : static function () use ($condition): mixed { + return $condition; + }; - if ($condition() === true) { + if ($condition()) { return $this->throws($exception, $exceptionMessage); } diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index cac11672..40ab0a49 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -695,5 +695,5 @@ ✓ it is a test ✓ it uses correct parent class - Tests: 4 incompleted, 9 skipped, 454 passed + Tests: 4 incompleted, 9 skipped, 459 passed \ No newline at end of file