diff --git a/overrides/Runner/ResultCache/DefaultResultCache.php b/overrides/Runner/ResultCache/DefaultResultCache.php index 49cdd14c..b798351d 100644 --- a/overrides/Runner/ResultCache/DefaultResultCache.php +++ b/overrides/Runner/ResultCache/DefaultResultCache.php @@ -86,7 +86,7 @@ final class DefaultResultCache implements ResultCache */ private array $times = []; - public function __construct(string $filepath = null) + public function __construct(?string $filepath = null) { if ($filepath !== null && is_dir($filepath)) { $filepath .= DIRECTORY_SEPARATOR.self::DEFAULT_RESULT_CACHE_FILENAME; diff --git a/src/Expectation.php b/src/Expectation.php index 9a327efa..4f524692 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -190,7 +190,7 @@ final class Expectation * * @return EachExpectation */ - public function each(callable $callback = null): EachExpectation + public function each(?callable $callback = null): EachExpectation { if (! is_iterable($this->value)) { throw new BadMethodCallException('Expectation value is not iterable.'); diff --git a/src/Functions.php b/src/Functions.php index 465f3add..34595794 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -55,7 +55,7 @@ if (! function_exists('beforeEach')) { * * @return HigherOrderTapProxy|Expectable|TestCall|TestCase|mixed */ - function beforeEach(Closure $closure = null): BeforeEachCall + function beforeEach(?Closure $closure = null): BeforeEachCall { $filename = Backtrace::file(); @@ -116,7 +116,7 @@ if (! function_exists('test')) { * * @return Expectable|TestCall|TestCase|mixed */ - function test(string $description = null, Closure $closure = null): HigherOrderTapProxy|TestCall + function test(?string $description = null, ?Closure $closure = null): HigherOrderTapProxy|TestCall { if ($description === null && TestSuite::getInstance()->test instanceof \PHPUnit\Framework\TestCase) { return new HigherOrderTapProxy(TestSuite::getInstance()->test); @@ -136,7 +136,7 @@ if (! function_exists('it')) { * * @return Expectable|TestCall|TestCase|mixed */ - function it(string $description, Closure $closure = null): TestCall + function it(string $description, ?Closure $closure = null): TestCall { $description = sprintf('it %s', $description); @@ -171,7 +171,7 @@ if (! function_exists('afterEach')) { * * @return Expectable|HigherOrderTapProxy|TestCall|mixed */ - function afterEach(Closure $closure = null): AfterEachCall + function afterEach(?Closure $closure = null): AfterEachCall { $filename = Backtrace::file(); diff --git a/src/Logging/TeamCity/ServiceMessage.php b/src/Logging/TeamCity/ServiceMessage.php index 1f3f2edf..ace7f40b 100644 --- a/src/Logging/TeamCity/ServiceMessage.php +++ b/src/Logging/TeamCity/ServiceMessage.php @@ -106,7 +106,7 @@ final class ServiceMessage ]); } - public static function testIgnored(string $name, string $message, string $details = null): self + public static function testIgnored(string $name, string $message, ?string $details = null): self { return new self('testIgnored', [ 'name' => $name, diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index a9edcf07..9b1e07a8 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -920,7 +920,7 @@ final class Expectation * @param (Closure(Throwable): mixed)|string $exception * @return self */ - public function toThrow(callable|string|Throwable $exception, string $exceptionMessage = null, string $message = ''): self + public function toThrow(callable|string|Throwable $exception, ?string $exceptionMessage = null, string $message = ''): self { $callback = NullClosure::create(); diff --git a/src/PendingCalls/AfterEachCall.php b/src/PendingCalls/AfterEachCall.php index 9a22258e..a20157e9 100644 --- a/src/PendingCalls/AfterEachCall.php +++ b/src/PendingCalls/AfterEachCall.php @@ -35,7 +35,7 @@ final class AfterEachCall public function __construct( private readonly TestSuite $testSuite, private readonly string $filename, - Closure $closure = null + ?Closure $closure = null ) { $this->closure = $closure instanceof Closure ? $closure : NullClosure::create(); diff --git a/src/PendingCalls/BeforeEachCall.php b/src/PendingCalls/BeforeEachCall.php index 200c4fa9..2be5510d 100644 --- a/src/PendingCalls/BeforeEachCall.php +++ b/src/PendingCalls/BeforeEachCall.php @@ -40,7 +40,7 @@ final class BeforeEachCall public function __construct( public readonly TestSuite $testSuite, private readonly string $filename, - Closure $closure = null + ?Closure $closure = null ) { $this->closure = $closure instanceof Closure ? $closure : NullClosure::create(); diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 07053131..3586cdcc 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -51,8 +51,8 @@ final class TestCall public function __construct( private readonly TestSuite $testSuite, private readonly string $filename, - string $description = null, - Closure $closure = null + ?string $description = null, + ?Closure $closure = null ) { $this->testCaseMethod = new TestCaseMethodFactory($filename, $description, $closure); @@ -66,7 +66,7 @@ final class TestCall /** * Asserts that the test fails with the given message. */ - public function fails(string $message = null): self + public function fails(?string $message = null): self { return $this->throws(AssertionFailedError::class, $message); } @@ -74,7 +74,7 @@ final class TestCall /** * Asserts that the test throws the given `$exceptionClass` when called. */ - public function throws(string|int $exception, string $exceptionMessage = null, int $exceptionCode = null): self + public function throws(string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self { if (is_int($exception)) { $exceptionCode = $exception; @@ -106,7 +106,7 @@ final class TestCall * * @param (callable(): bool)|bool $condition */ - public function throwsIf(callable|bool $condition, string|int $exception, string $exceptionMessage = null, int $exceptionCode = null): self + public function throwsIf(callable|bool $condition, string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self { $condition = is_callable($condition) ? $condition @@ -124,7 +124,7 @@ final class TestCall * * @param (callable(): bool)|bool $condition */ - public function throwsUnless(callable|bool $condition, string|int $exception, string $exceptionMessage = null, int $exceptionCode = null): self + public function throwsUnless(callable|bool $condition, string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self { $condition = is_callable($condition) ? $condition @@ -401,7 +401,7 @@ final class TestCall * * @param array|null $arguments */ - private function addChain(string $file, int $line, string $name, array $arguments = null): self + private function addChain(string $file, int $line, string $name, ?array $arguments = null): self { $exporter = Exporter::default(); diff --git a/src/Plugins/Environment.php b/src/Plugins/Environment.php index aebe2343..8ff10b4c 100644 --- a/src/Plugins/Environment.php +++ b/src/Plugins/Environment.php @@ -45,7 +45,7 @@ final class Environment implements HandlesArguments /** * Gets the environment name. */ - public static function name(string $name = null): string + public static function name(?string $name = null): string { if (is_string($name)) { self::$name = $name; diff --git a/src/Support/Exporter.php b/src/Support/Exporter.php index 313d081f..ea02ce61 100644 --- a/src/Support/Exporter.php +++ b/src/Support/Exporter.php @@ -41,7 +41,7 @@ final class Exporter * * @param array $data */ - public function shortenedRecursiveExport(array &$data, Context $context = null): string + public function shortenedRecursiveExport(array &$data, ?Context $context = null): string { $result = []; $array = $data; diff --git a/src/TestSuite.php b/src/TestSuite.php index 885baa2f..496eb0ce 100644 --- a/src/TestSuite.php +++ b/src/TestSuite.php @@ -87,8 +87,8 @@ final class TestSuite * Returns the current instance of the test suite. */ public static function getInstance( - string $rootPath = null, - string $testPath = null, + ?string $rootPath = null, + ?string $testPath = null, ): TestSuite { if (is_string($rootPath) && is_string($testPath)) { self::$instance = new TestSuite($rootPath, $testPath);