Skip to content

Commit 8abdae0

Browse files
committed
style: apply fixes from phpstan
1 parent e70ef1f commit 8abdae0

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

tests/Integration/Http/DatabaseSessionTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPUnit\Framework\Attributes\PreCondition;
88
use PHPUnit\Framework\Attributes\Test;
99
use Tempest\Clock\Clock;
10-
use Tempest\Database\Database;
1110
use Tempest\Database\Migrations\CreateMigrationsTable;
1211
use Tempest\DateTime\Duration;
1312
use Tempest\Http\Session\Config\DatabaseSessionConfig;
@@ -30,7 +29,7 @@
3029
*/
3130
final class DatabaseSessionTest extends FrameworkIntegrationTestCase
3231
{
33-
private DatabaseSessionManager $manager {
32+
private SessionManager $manager {
3433
get => $this->container->get(SessionManager::class);
3534
}
3635

@@ -46,7 +45,6 @@ protected function configure(): void
4645
$this->container->singleton(SessionManager::class, fn () => new DatabaseSessionManager(
4746
$this->container->get(Clock::class),
4847
$this->container->get(SessionConfig::class),
49-
$this->container->get(Database::class),
5048
));
5149

5250
$this->database->reset(migrate: false);

tests/Integration/Http/FileSessionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class FileSessionTest extends FrameworkIntegrationTestCase
2929
{
3030
private string $path = __DIR__ . '/Fixtures/tmp';
3131

32-
private FileSessionManager $manager {
32+
private SessionManager $manager {
3333
get => $this->container->get(SessionManager::class);
3434
}
3535

tests/Integration/Http/FormSessionTest.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHPUnit\Framework\Attributes\Test;
88
use Tempest\Http\Session\FormSession;
99
use Tempest\Http\Session\Session;
10+
use Tempest\Validation\FailingRule;
1011
use Tempest\Validation\Rules\HasLength;
1112
use Tests\Tempest\Integration\FrameworkIntegrationTestCase;
1213

@@ -27,8 +28,8 @@ final class FormSessionTest extends FrameworkIntegrationTestCase
2728
public function flash_errors_stores_errors(): void
2829
{
2930
$errors = [
30-
'name' => [new HasLength(min: 3)],
31-
'email' => [new HasLength(min: 5)],
31+
'name' => [new FailingRule(new HasLength(min: 3))],
32+
'email' => [new FailingRule(new HasLength(min: 5))],
3233
];
3334

3435
$this->formSession->setErrors($errors);
@@ -39,8 +40,8 @@ public function flash_errors_stores_errors(): void
3940
#[Test]
4041
public function errors_for_returns_field_specific_errors(): void
4142
{
42-
$nameError = new HasLength(min: 3);
43-
$emailError = new HasLength(min: 5);
43+
$nameError = new FailingRule(new HasLength(min: 3));
44+
$emailError = new FailingRule(new HasLength(min: 5));
4445

4546
$this->formSession->setErrors([
4647
'name' => [$nameError],
@@ -55,7 +56,7 @@ public function errors_for_returns_field_specific_errors(): void
5556
public function errors_for_returns_empty_array_when_field_has_no_errors(): void
5657
{
5758
$this->formSession->setErrors([
58-
'name' => [new HasLength(min: 3)],
59+
'name' => [new FailingRule(new HasLength(min: 3))],
5960
]);
6061

6162
$this->assertEquals([], $this->formSession->getErrorsFor('email'));
@@ -65,7 +66,7 @@ public function errors_for_returns_empty_array_when_field_has_no_errors(): void
6566
public function has_errors_returns_true_when_errors_exist(): void
6667
{
6768
$this->formSession->setErrors([
68-
'name' => [new HasLength(min: 3)],
69+
'name' => [new FailingRule(new HasLength(min: 3))],
6970
]);
7071

7172
$this->assertTrue($this->formSession->hasErrors());
@@ -81,7 +82,7 @@ public function has_errors_returns_false_when_no_errors(): void
8182
public function has_error_returns_true_when_field_has_errors(): void
8283
{
8384
$this->formSession->setErrors([
84-
'name' => [new HasLength(min: 3)],
85+
'name' => [new FailingRule(new HasLength(min: 3))],
8586
]);
8687

8788
$this->assertTrue($this->formSession->hasError('name'));
@@ -91,7 +92,7 @@ public function has_error_returns_true_when_field_has_errors(): void
9192
public function has_error_returns_false_when_field_has_no_errors(): void
9293
{
9394
$this->formSession->setErrors([
94-
'name' => [new HasLength(min: 3)],
95+
'name' => [new FailingRule(new HasLength(min: 3))],
9596
]);
9697

9798
$this->assertFalse($this->formSession->hasError('email'));
@@ -143,7 +144,7 @@ public function value_returns_default_when_field_not_found(): void
143144
public function clear_removes_errors_and_values(): void
144145
{
145146
$this->formSession->setErrors([
146-
'name' => [new HasLength(min: 3)],
147+
'name' => [new FailingRule(new HasLength(min: 3))],
147148
]);
148149
$this->formSession->setOriginalValues([
149150
'name' => 'John',
@@ -159,7 +160,7 @@ public function clear_removes_errors_and_values(): void
159160
public function errors_are_flashed_and_cleared_after_next_request(): void
160161
{
161162
$this->formSession->setErrors([
162-
'name' => [new HasLength(min: 3)],
163+
'name' => [new FailingRule(new HasLength(min: 3))],
163164
]);
164165

165166
// First access - errors exist

tests/Integration/Http/RedisSessionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
final class RedisSessionTest extends FrameworkIntegrationTestCase
3030
{
31-
private RedisSessionManager $manager {
31+
private SessionManager $manager {
3232
get => $this->container->get(SessionManager::class);
3333
}
3434

@@ -47,7 +47,7 @@ protected function configure(): void
4747
$this->container->singleton(SessionManager::class, fn () => new RedisSessionManager(
4848
clock: $this->container->get(Clock::class),
4949
redis: $this->container->get(Redis::class),
50-
config: $this->container->get(SessionConfig::class),
50+
config: $this->container->get(RedisSessionConfig::class),
5151
));
5252

5353
try {

tests/Integration/View/Components/InputComponentTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Tests\Tempest\Integration\View\Components;
44

55
use Tempest\Http\Session\FormSession;
6+
use Tempest\Validation\FailingRule;
67
use Tempest\Validation\Rules\HasLength;
78
use Tempest\Validation\Rules\IsInteger;
89
use Tempest\Validation\Rules\IsString;
@@ -77,11 +78,11 @@ public function test_error_message(): void
7778
{
7879
$failingRules = [
7980
'name' => [
80-
new IsString(),
81-
new HasLength(min: 5),
81+
new FailingRule(new IsString()),
82+
new FailingRule(new HasLength(min: 5)),
8283
],
8384
'other' => [
84-
new IsInteger(),
85+
new FailingRule(new IsInteger()),
8586
],
8687
];
8788

tests/Integration/View/ViewComponentTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Tempest\Core\AppConfig;
1010
use Tempest\Core\Environment;
1111
use Tempest\Http\Session\FormSession;
12+
use Tempest\Validation\FailingRule;
1213
use Tempest\Validation\Rules\IsAlphaNumeric;
1314
use Tempest\Validation\Rules\IsBetween;
1415
use Tempest\Validation\Validator;
@@ -215,8 +216,8 @@ public function test_component_with_anther_component_included_with_slot(): void
215216

216217
public function test_view_component_with_injected_view(): void
217218
{
218-
$between = new IsBetween(min: 1, max: 10);
219-
$alphaNumeric = new IsAlphaNumeric();
219+
$between = new FailingRule(new IsBetween(min: 1, max: 10));
220+
$alphaNumeric = new FailingRule(new IsAlphaNumeric());
220221

221222
$formSession = $this->container->get(FormSession::class);
222223
$formSession->setErrors(

0 commit comments

Comments
 (0)