Skip to content

Commit 14b7284

Browse files
authored
style: apply rector post 3.10.0 release (#2128)
1 parent c8a13f7 commit 14b7284

10 files changed

Lines changed: 21 additions & 15 deletions

File tree

packages/database/src/Config/DatabaseDialect.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function encloseExpressionDefault(string $expression): string
3333
{
3434
return match ($this) {
3535
self::MYSQL => sprintf('(%s)', $expression),
36-
default => sprintf('%s', $expression),
36+
default => $expression,
3737
};
3838
}
3939

packages/database/src/IsDatabaseModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function query(string $relation): QueryBuilder
279279

280280
$resolved = $model->getRelation(name: $relation);
281281

282-
if ($resolved === null) {
282+
if (! $resolved instanceof Relation) {
283283
throw new PropertyWasNotARelation(property: $relation, model: $model->getName());
284284
}
285285

packages/database/tests/QueryStatements/CharStatementTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function test_char(): void
2020
default: '019d38a9-5504-7a16-ab9d-520bbc289ecc',
2121
);
2222

23-
$expectedMysql = '`foo` CHAR(36) DEFAULT \'019d38a9-5504-7a16-ab9d-520bbc289ecc\' NOT NULL';
23+
$expectedMysql = "`foo` CHAR(36) DEFAULT '019d38a9-5504-7a16-ab9d-520bbc289ecc' NOT NULL";
2424
$expectedPgsql = '"foo" CHAR(36) DEFAULT \'019d38a9-5504-7a16-ab9d-520bbc289ecc\' NOT NULL';
2525

2626
$this->assertSame($expectedMysql, $statement->compile(DatabaseDialect::MYSQL));
@@ -41,15 +41,15 @@ public function test_determine_char_size(): void
4141
name: 'foo',
4242
default: 'foo_bar',
4343
);
44-
$expectedMysql = '`foo` CHAR(7) DEFAULT \'foo_bar\' NOT NULL';
44+
$expectedMysql = "`foo` CHAR(7) DEFAULT 'foo_bar' NOT NULL";
4545
$this->assertSame($expectedMysql, $defaultSizeStatement->compile(DatabaseDialect::MYSQL));
4646

4747
$fixedAndDefaultSizeStatement = new CharStatement(
4848
name: 'foo',
4949
size: 7,
5050
default: 'foo_bar',
5151
);
52-
$expectedMysql = '`foo` CHAR(7) DEFAULT \'foo_bar\' NOT NULL';
52+
$expectedMysql = "`foo` CHAR(7) DEFAULT 'foo_bar' NOT NULL";
5353
$this->assertSame($expectedMysql, $fixedAndDefaultSizeStatement->compile(DatabaseDialect::MYSQL));
5454
}
5555

@@ -73,7 +73,7 @@ public function test_char_size_greater_than_default_value_length(): void
7373
size: 10,
7474
default: 'foo_bar',
7575
);
76-
$expectedMysql = '`foo` CHAR(10) DEFAULT \'foo_bar\' NOT NULL';
76+
$expectedMysql = "`foo` CHAR(10) DEFAULT 'foo_bar' NOT NULL";
7777
$this->assertSame($expectedMysql, $statement->compile(DatabaseDialect::MYSQL));
7878
}
7979
}

packages/database/tests/QueryStatements/DateStatementTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Tempest\Database\Tests\QueryStatements;
44

5+
use InvalidArgumentException;
56
use PHPUnit\Framework\Attributes\Test;
67
use PHPUnit\Framework\TestCase;
78
use Tempest\Database\Config\DatabaseDialect;
@@ -17,7 +18,7 @@ public function test_date(): void
1718
default: '2026-01-01',
1819
);
1920

20-
$expectedMysql = '`foo` DATE DEFAULT \'2026-01-01\' NOT NULL';
21+
$expectedMysql = "`foo` DATE DEFAULT '2026-01-01' NOT NULL";
2122
$expectedPgsql = '"foo" DATE DEFAULT \'2026-01-01\' NOT NULL';
2223

2324
$this->assertSame($expectedMysql, $statement->compile(DatabaseDialect::MYSQL));
@@ -43,7 +44,7 @@ public function test_date_with_current(): void
4344
#[Test]
4445
public function test_date_with_default_and_current(): void
4546
{
46-
$this->expectException(\InvalidArgumentException::class);
47+
$this->expectException(InvalidArgumentException::class);
4748

4849
$statement = new DateStatement(
4950
name: 'foo',

packages/discovery/src/Composer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Tempest\Process\ProcessExecutor;
88
use Tempest\Support\Arr;
9+
use Tempest\Support\Arr\ImmutableArray;
910
use Tempest\Support\Filesystem;
1011
use Tempest\Support\Namespace\Psr4Namespace;
1112
use Tempest\Support\Path;
@@ -50,7 +51,7 @@ public function load(): self
5051
$this->mainNamespace = $this->namespaces[0];
5152
}
5253

53-
$this->namespaces = new Arr\ImmutableArray([$this->mainNamespace, ...$this->namespaces])
54+
$this->namespaces = new ImmutableArray([$this->mainNamespace, ...$this->namespaces])
5455
->filter()
5556
->unique(fn (Psr4Namespace $ns) => "{$ns->namespace}:{$ns->path}")
5657
->toArray();
@@ -120,8 +121,8 @@ private function loadComposerFile(string $path): array
120121
/** @return array<Psr4Namespace> */
121122
private function resolvePsr4Namespaces(string $path): array
122123
{
123-
return new Arr\ImmutableArray($this->composer)
124-
->get($path, default: new Arr\ImmutableArray())
124+
return new ImmutableArray($this->composer)
125+
->get($path, default: new ImmutableArray())
125126
->flatMap(fn (string|iterable $paths, string $namespace) => Arr\map(Arr\wrap($paths), fn (string $path) => new Psr4Namespace($namespace, $path)))
126127
->sortByCallback(fn (Psr4Namespace $ns1, Psr4Namespace $ns2) => strlen($ns1->path) <=> strlen($ns2->path))
127128
->values()

packages/mapper/src/Casters/BooleanCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function cast(mixed $input): ?bool
3939
$input = mb_strtolower(trim($input));
4040
}
4141

42-
if ($this->nullable && ($input === null || $input === '' || $input === 'null')) {
42+
if ($this->nullable && in_array($input, [null, '', 'null'], true)) {
4343
return null;
4444
}
4545

packages/mapper/src/Casters/FloatCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function cast(mixed $input): ?float
3939
$input = mb_strtolower(trim($input));
4040
}
4141

42-
if ($this->nullable && ($input === null || $input === '' || $input === 'null')) {
42+
if ($this->nullable && in_array($input, [null, '', 'null'], true)) {
4343
return null;
4444
}
4545

packages/mapper/src/Casters/IntegerCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function cast(mixed $input): ?int
3939
$input = mb_strtolower(trim($input));
4040
}
4141

42-
if ($this->nullable && ($input === null || $input === '' || $input === 'null')) {
42+
if ($this->nullable && in_array($input, [null, '', 'null'], true)) {
4343
return null;
4444
}
4545

packages/upgrade/src/Tempest310/UpdatePriorityImportsRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
final class UpdatePriorityImportsRector extends AbstractRector
1212
{
1313
private const string OLD_CLASS = 'Tempest\Core\Priority';
14+
1415
private const string NEW_CLASS = 'Tempest\Support\Priority';
1516

1617
public function getNodeTypes(): array

tests/Integration/Core/FrameworkKernelExceptionHandlerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ public function warnings_notices_and_deprecations_are_processed_without_throwing
5353

5454
$this->container->singleton(ExceptionHandler::class, new TestingExceptionHandler());
5555
$this->container->singleton(ExceptionProcessor::class, $processor = new TestingExceptionProcessor());
56+
5657
$this->kernel->registerExceptionHandler();
5758

5859
try {
5960
trigger_error('report warning', E_USER_WARNING);
6061
trigger_error('report deprecation', E_USER_DEPRECATED);
6162
trigger_error('report notice', E_USER_NOTICE);
6263
} catch (Throwable $throwable) {
63-
$this->fail(sprintf('Expected no exception to be thrown, but got %s: %s', get_class($throwable), $throwable->getMessage()));
64+
$this->fail(sprintf('Expected no exception to be thrown, but got %s: %s', $throwable::class, $throwable->getMessage()));
6465
}
6566

6667
$this->assertCount(3, $processor->processed);
@@ -91,6 +92,7 @@ public function suppressions_are_not_processed_or_thrown(): void
9192

9293
$this->container->singleton(ExceptionHandler::class, new TestingExceptionHandler());
9394
$this->container->singleton(ExceptionProcessor::class, $processor = new TestingExceptionProcessor());
95+
9496
$this->kernel->registerExceptionHandler();
9597

9698
@trigger_error('suppressed warning', E_USER_WARNING);
@@ -109,6 +111,7 @@ public function uncaught_exceptions_are_forwarded_to_the_registered_exception_ha
109111

110112
$this->container->singleton(ExceptionHandler::class, $handler);
111113
$this->container->singleton(ExceptionProcessor::class, new TestingExceptionProcessor());
114+
112115
$this->kernel->registerExceptionHandler();
113116

114117
$kernelExceptionHandler = set_exception_handler(static function (Throwable $throwable): void {});

0 commit comments

Comments
 (0)