From 3c3e6b160bbfd9f040e4b601fbae369588c7e8e7 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 24 Sep 2021 21:10:02 +0100 Subject: [PATCH] refactor: expectation when --- src/Expectation.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Expectation.php b/src/Expectation.php index 7a1e6057..d39d0904 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -178,15 +178,16 @@ final class Expectation } /** - * It skips the tests in the callback if the condition is not truthy. + * Apply the callback if the given "condition" is truthy. * - * @param Closure|bool|string $condition + * @param (callable(): bool)|bool $condition + * @param callable(Expectation): mixed $callback */ public function when($condition, callable $callback): Expectation { $condition = is_callable($condition) ? $condition - : function () use ($condition) { + : static function () use ($condition): mixed { return $condition; };