chore: code style changes

This commit is contained in:
Nuno Maduro
2023-12-15 11:42:09 +00:00
parent dd0dddffd4
commit 453133d382
11 changed files with 20 additions and 20 deletions

View File

@ -91,7 +91,7 @@ final class DefaultResultCache implements ResultCache
*/ */
private array $times = []; private array $times = [];
public function __construct(string $filepath = null) public function __construct(?string $filepath = null)
{ {
if ($filepath !== null && is_dir($filepath)) { if ($filepath !== null && is_dir($filepath)) {
$filepath .= DIRECTORY_SEPARATOR.self::DEFAULT_RESULT_CACHE_FILENAME; $filepath .= DIRECTORY_SEPARATOR.self::DEFAULT_RESULT_CACHE_FILENAME;

View File

@ -190,7 +190,7 @@ final class Expectation
* *
* @return EachExpectation<TValue> * @return EachExpectation<TValue>
*/ */
public function each(callable $callback = null): EachExpectation public function each(?callable $callback = null): EachExpectation
{ {
if (! is_iterable($this->value)) { if (! is_iterable($this->value)) {
throw new BadMethodCallException('Expectation value is not iterable.'); throw new BadMethodCallException('Expectation value is not iterable.');

View File

@ -55,7 +55,7 @@ if (! function_exists('beforeEach')) {
* *
* @return HigherOrderTapProxy<Expectable|TestCall|TestCase>|Expectable|TestCall|TestCase|mixed * @return HigherOrderTapProxy<Expectable|TestCall|TestCase>|Expectable|TestCall|TestCase|mixed
*/ */
function beforeEach(Closure $closure = null): BeforeEachCall function beforeEach(?Closure $closure = null): BeforeEachCall
{ {
$filename = Backtrace::file(); $filename = Backtrace::file();
@ -116,7 +116,7 @@ if (! function_exists('test')) {
* *
* @return Expectable|TestCall|TestCase|mixed * @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) { if ($description === null && TestSuite::getInstance()->test instanceof \PHPUnit\Framework\TestCase) {
return new HigherOrderTapProxy(TestSuite::getInstance()->test); return new HigherOrderTapProxy(TestSuite::getInstance()->test);
@ -136,7 +136,7 @@ if (! function_exists('it')) {
* *
* @return Expectable|TestCall|TestCase|mixed * @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); $description = sprintf('it %s', $description);
@ -171,7 +171,7 @@ if (! function_exists('afterEach')) {
* *
* @return Expectable|HigherOrderTapProxy<Expectable|TestCall|TestCase>|TestCall|mixed * @return Expectable|HigherOrderTapProxy<Expectable|TestCall|TestCase>|TestCall|mixed
*/ */
function afterEach(Closure $closure = null): AfterEachCall function afterEach(?Closure $closure = null): AfterEachCall
{ {
$filename = Backtrace::file(); $filename = Backtrace::file();

View File

@ -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', [ return new self('testIgnored', [
'name' => $name, 'name' => $name,

View File

@ -920,7 +920,7 @@ final class Expectation
* @param (Closure(Throwable): mixed)|string $exception * @param (Closure(Throwable): mixed)|string $exception
* @return self<TValue> * @return self<TValue>
*/ */
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(); $callback = NullClosure::create();

View File

@ -35,7 +35,7 @@ final class AfterEachCall
public function __construct( public function __construct(
private readonly TestSuite $testSuite, private readonly TestSuite $testSuite,
private readonly string $filename, private readonly string $filename,
Closure $closure = null ?Closure $closure = null
) { ) {
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create(); $this->closure = $closure instanceof Closure ? $closure : NullClosure::create();

View File

@ -40,7 +40,7 @@ final class BeforeEachCall
public function __construct( public function __construct(
public readonly TestSuite $testSuite, public readonly TestSuite $testSuite,
private readonly string $filename, private readonly string $filename,
Closure $closure = null ?Closure $closure = null
) { ) {
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create(); $this->closure = $closure instanceof Closure ? $closure : NullClosure::create();

View File

@ -45,8 +45,8 @@ final class TestCall
public function __construct( public function __construct(
private readonly TestSuite $testSuite, private readonly TestSuite $testSuite,
private readonly string $filename, private readonly string $filename,
string $description = null, ?string $description = null,
Closure $closure = null ?Closure $closure = null
) { ) {
$this->testCaseMethod = new TestCaseMethodFactory($filename, $description, $closure); $this->testCaseMethod = new TestCaseMethodFactory($filename, $description, $closure);
@ -60,7 +60,7 @@ final class TestCall
/** /**
* Asserts that the test throws the given `$exceptionClass` when called. * 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)) { if (is_int($exception)) {
$exceptionCode = $exception; $exceptionCode = $exception;
@ -92,7 +92,7 @@ final class TestCall
* *
* @param (callable(): bool)|bool $condition * @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 = is_callable($condition)
? $condition ? $condition
@ -110,7 +110,7 @@ final class TestCall
* *
* @param (callable(): bool)|bool $condition * @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 = is_callable($condition)
? $condition ? $condition
@ -375,7 +375,7 @@ final class TestCall
* *
* @param array<int, mixed>|null $arguments * @param array<int, mixed>|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(); $exporter = Exporter::default();

View File

@ -45,7 +45,7 @@ final class Environment implements HandlesArguments
/** /**
* Gets the environment name. * Gets the environment name.
*/ */
public static function name(string $name = null): string public static function name(?string $name = null): string
{ {
if (is_string($name)) { if (is_string($name)) {
self::$name = $name; self::$name = $name;

View File

@ -41,7 +41,7 @@ final class Exporter
* *
* @param array<int|string, mixed> $data * @param array<int|string, mixed> $data
*/ */
public function shortenedRecursiveExport(array &$data, Context $context = null): string public function shortenedRecursiveExport(array &$data, ?Context $context = null): string
{ {
$result = []; $result = [];
$array = $data; $array = $data;

View File

@ -87,8 +87,8 @@ final class TestSuite
* Returns the current instance of the test suite. * Returns the current instance of the test suite.
*/ */
public static function getInstance( public static function getInstance(
string $rootPath = null, ?string $rootPath = null,
string $testPath = null, ?string $testPath = null,
): TestSuite { ): TestSuite {
if (is_string($rootPath) && is_string($testPath)) { if (is_string($rootPath) && is_string($testPath)) {
self::$instance = new TestSuite($rootPath, $testPath); self::$instance = new TestSuite($rootPath, $testPath);