Skip to content
Merged
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/container/src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function config(object $config): self;
/**
* @template TClassName of object
* @param class-string<TClassName> $className
* @return null|TClassName
* @return TClassName
*/
public function get(string $className, null|string|UnitEnum $tag = null, mixed ...$params): mixed;

Expand Down
10 changes: 5 additions & 5 deletions packages/container/src/GenericContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public function config(object $config): self
/**
* @template TClassName of object
* @param class-string<TClassName> $className
* @return null|TClassName
* @return TClassName
*/
public function get(string $className, null|string|UnitEnum $tag = null, mixed ...$params): ?object
public function get(string $className, null|string|UnitEnum $tag = null, mixed ...$params): object
{
$this->resolveChain();

Expand Down Expand Up @@ -325,7 +325,7 @@ public function addDecorator(ClassReflector|string $decoratorClass, ClassReflect
return $this;
}

private function resolve(string $className, null|string|UnitEnum $tag = null, mixed ...$params): ?object
private function resolve(string $className, null|string|UnitEnum $tag = null, mixed ...$params): object
{
$instance = $this->resolveDependency($className, $tag, ...$params);

Expand All @@ -336,7 +336,7 @@ private function resolve(string $className, null|string|UnitEnum $tag = null, mi
return $instance;
}

private function resolveDependency(string $className, null|string|UnitEnum $tag = null, mixed ...$params): ?object
private function resolveDependency(string $className, null|string|UnitEnum $tag = null, mixed ...$params): object
{
$class = new ClassReflector($className);

Expand Down Expand Up @@ -646,7 +646,7 @@ private function resolveTaggedName(string $className, null|string|UnitEnum $tag)
: $className;
}

private function resolveDecorator(string $className, mixed $instance, null|string|UnitEnum $tag = null, mixed ...$params): ?object
private function resolveDecorator(string $className, mixed $instance, null|string|UnitEnum $tag = null, mixed ...$params): object
{
foreach ($this->decorators[$className] ?? [] as $decoratorClass) {
$decoratorClassReflector = new ClassReflector($decoratorClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Tests\Tempest\Integration\Database\QueryStatements;

use PHPUnit\Framework\Attributes\Test;
use RuntimeException;
use Tempest\Database\Config\DatabaseConfig;
use Tempest\Database\Config\DatabaseDialect;
use Tempest\Database\Exceptions\QueryWasInvalid;
Expand Down Expand Up @@ -45,11 +44,10 @@ public function test_it_can_alter_a_table_definition(): void
email: '[email protected]',
);
} catch (QueryWasInvalid $queryWasInvalid) {
$message = match ($this->container->get(DatabaseConfig::class)?->dialect) {
$message = match ($this->container->get(DatabaseConfig::class)->dialect) {
DatabaseDialect::MYSQL => "Unknown column 'email'",
DatabaseDialect::SQLITE => 'table users has no column named email',
DatabaseDialect::POSTGRESQL => 'column "email" of relation "users" does not exist',
null => throw new RuntimeException('No database dialect available'),
};

$this->assertStringContainsString($message, $queryWasInvalid->getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Tests\Tempest\Integration\Database\QueryStatements;

use RuntimeException;
use Tempest\Database\Config\DatabaseConfig;
use Tempest\Database\Config\DatabaseDialect;
use Tempest\Database\Database;
Expand Down Expand Up @@ -67,12 +66,12 @@ public function up(): QueryStatement
}
};

$dialect = $this->container->get(DatabaseConfig::class)?->dialect;
$dialect = $this->container->get(DatabaseConfig::class)->dialect;

match ($dialect) {
DatabaseDialect::MYSQL => $this->expectNotToPerformAssertions(),
DatabaseDialect::SQLITE => $this->expectException(DialectWasNotSupported::class),
DatabaseDialect::POSTGRESQL => $this->expectException(DialectWasNotSupported::class),
null => throw new RuntimeException('No database dialect available'),
};

$this->migrate(
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/View/Components/IconComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function test_it_caches_icons_on_the_first_render(): void
$this->render('<x-icon name="ph:eye" />');

$iconCache = $this->container->get(IconCache::class);
$cachedIcon = $iconCache?->get('icon-ph-eye');
$cachedIcon = $iconCache->get('icon-ph-eye');

$this->assertNotNull($cachedIcon);
$this->assertSame('<svg></svg>', $cachedIcon);
Expand Down
Loading