From 729d7c4bef5efa48671ce7b8d335d964c64f432e Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 27 Nov 2021 07:44:35 +0000 Subject: [PATCH] Small tweaks for PHP 8 --- src/Factories/TestCaseFactory.php | 7 ++++--- src/Factories/TestCaseMethodFactory.php | 9 ++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index f6a61ba2..448734cc 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -73,9 +73,10 @@ final class TestCaseFactory { $methodsUsingOnly = $this->methodsUsingOnly(); - $methods = array_values(array_filter($this->methods, function ($method) use ($methodsUsingOnly) { - return count($methodsUsingOnly) === 0 || in_array($method, $methodsUsingOnly, true); - })); + $methods = array_values(array_filter( + $this->methods, + fn ($method) => count($methodsUsingOnly) === 0 || in_array($method, $methodsUsingOnly, true) + )); if (count($methods) > 0) { $this->evaluate($this->filename, $methods); diff --git a/src/Factories/TestCaseMethodFactory.php b/src/Factories/TestCaseMethodFactory.php index 540f2677..5de47009 100644 --- a/src/Factories/TestCaseMethodFactory.php +++ b/src/Factories/TestCaseMethodFactory.php @@ -17,6 +17,7 @@ use PHPUnit\Framework\TestCase; final class TestCaseMethodFactory { use HigherOrderable; + /** * Determines if the Test Case will be the "only" being run. */ @@ -51,11 +52,9 @@ final class TestCaseMethodFactory public ?string $description, public ?Closure $closure, ) { - if ($this->closure === null) { - $this->closure = function () { - Assert::getCount() > 0 ?: self::markTestIncomplete(); // @phpstan-ignore-line - }; - } + $this->closure ??= function () { + Assert::getCount() > 0 ?: self::markTestIncomplete(); // @phpstan-ignore-line + }; $this->bootHigherOrderable(); }