Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/database/src/Config/DatabaseDialect.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function encloseExpressionDefault(string $expression): string
{
return match ($this) {
self::MYSQL => sprintf('(%s)', $expression),
default => sprintf('%s', $expression),
default => $expression,
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/database/src/IsDatabaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function query(string $relation): QueryBuilder

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function test_char(): void
default: '019d38a9-5504-7a16-ab9d-520bbc289ecc',
);

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

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

$fixedAndDefaultSizeStatement = new CharStatement(
name: 'foo',
size: 7,
default: 'foo_bar',
);
$expectedMysql = '`foo` CHAR(7) DEFAULT \'foo_bar\' NOT NULL';
$expectedMysql = "`foo` CHAR(7) DEFAULT 'foo_bar' NOT NULL";
$this->assertSame($expectedMysql, $fixedAndDefaultSizeStatement->compile(DatabaseDialect::MYSQL));
}

Expand All @@ -73,7 +73,7 @@ public function test_char_size_greater_than_default_value_length(): void
size: 10,
default: 'foo_bar',
);
$expectedMysql = '`foo` CHAR(10) DEFAULT \'foo_bar\' NOT NULL';
$expectedMysql = "`foo` CHAR(10) DEFAULT 'foo_bar' NOT NULL";
$this->assertSame($expectedMysql, $statement->compile(DatabaseDialect::MYSQL));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tempest\Database\Tests\QueryStatements;

use InvalidArgumentException;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Tempest\Database\Config\DatabaseDialect;
Expand All @@ -17,7 +18,7 @@ public function test_date(): void
default: '2026-01-01',
);

$expectedMysql = '`foo` DATE DEFAULT \'2026-01-01\' NOT NULL';
$expectedMysql = "`foo` DATE DEFAULT '2026-01-01' NOT NULL";
$expectedPgsql = '"foo" DATE DEFAULT \'2026-01-01\' NOT NULL';

$this->assertSame($expectedMysql, $statement->compile(DatabaseDialect::MYSQL));
Expand All @@ -43,7 +44,7 @@ public function test_date_with_current(): void
#[Test]
public function test_date_with_default_and_current(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);

$statement = new DateStatement(
name: 'foo',
Expand Down
7 changes: 4 additions & 3 deletions packages/discovery/src/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Tempest\Process\ProcessExecutor;
use Tempest\Support\Arr;
use Tempest\Support\Arr\ImmutableArray;
use Tempest\Support\Filesystem;
use Tempest\Support\Namespace\Psr4Namespace;
use Tempest\Support\Path;
Expand Down Expand Up @@ -50,7 +51,7 @@ public function load(): self
$this->mainNamespace = $this->namespaces[0];
}

$this->namespaces = new Arr\ImmutableArray([$this->mainNamespace, ...$this->namespaces])
$this->namespaces = new ImmutableArray([$this->mainNamespace, ...$this->namespaces])
->filter()
->unique(fn (Psr4Namespace $ns) => "{$ns->namespace}:{$ns->path}")
->toArray();
Expand Down Expand Up @@ -120,8 +121,8 @@ private function loadComposerFile(string $path): array
/** @return array<Psr4Namespace> */
private function resolvePsr4Namespaces(string $path): array
{
return new Arr\ImmutableArray($this->composer)
->get($path, default: new Arr\ImmutableArray())
return new ImmutableArray($this->composer)
->get($path, default: new ImmutableArray())
->flatMap(fn (string|iterable $paths, string $namespace) => Arr\map(Arr\wrap($paths), fn (string $path) => new Psr4Namespace($namespace, $path)))
->sortByCallback(fn (Psr4Namespace $ns1, Psr4Namespace $ns2) => strlen($ns1->path) <=> strlen($ns2->path))
->values()
Expand Down
2 changes: 1 addition & 1 deletion packages/mapper/src/Casters/BooleanCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function cast(mixed $input): ?bool
$input = mb_strtolower(trim($input));
}

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

Expand Down
2 changes: 1 addition & 1 deletion packages/mapper/src/Casters/FloatCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function cast(mixed $input): ?float
$input = mb_strtolower(trim($input));
}

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

Expand Down
2 changes: 1 addition & 1 deletion packages/mapper/src/Casters/IntegerCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function cast(mixed $input): ?int
$input = mb_strtolower(trim($input));
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
final class UpdatePriorityImportsRector extends AbstractRector
{
private const string OLD_CLASS = 'Tempest\Core\Priority';

private const string NEW_CLASS = 'Tempest\Support\Priority';

public function getNodeTypes(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ public function warnings_notices_and_deprecations_are_processed_without_throwing

$this->container->singleton(ExceptionHandler::class, new TestingExceptionHandler());
$this->container->singleton(ExceptionProcessor::class, $processor = new TestingExceptionProcessor());

$this->kernel->registerExceptionHandler();

try {
trigger_error('report warning', E_USER_WARNING);
trigger_error('report deprecation', E_USER_DEPRECATED);
trigger_error('report notice', E_USER_NOTICE);
} catch (Throwable $throwable) {
$this->fail(sprintf('Expected no exception to be thrown, but got %s: %s', get_class($throwable), $throwable->getMessage()));
$this->fail(sprintf('Expected no exception to be thrown, but got %s: %s', $throwable::class, $throwable->getMessage()));
}

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

$this->container->singleton(ExceptionHandler::class, new TestingExceptionHandler());
$this->container->singleton(ExceptionProcessor::class, $processor = new TestingExceptionProcessor());

$this->kernel->registerExceptionHandler();

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

$this->container->singleton(ExceptionHandler::class, $handler);
$this->container->singleton(ExceptionProcessor::class, new TestingExceptionProcessor());

$this->kernel->registerExceptionHandler();

$kernelExceptionHandler = set_exception_handler(static function (Throwable $throwable): void {});
Expand Down
Loading