Skip to content

Commit e555763

Browse files
committed
tests(phpstan): fix phpstan missing types and deprecations in php 8
1 parent be71187 commit e555763

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

tests/ContainerTest.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function test_it_can_resolve_a_class_with_a_constructor_with_default_valu
2222

2323
self::assertInstanceOf(
2424
DateTimeImmutable::class,
25-
$container->get(DateTimeImmutable::class)
25+
@$container->get(DateTimeImmutable::class)
2626
);
2727
}
2828

@@ -50,7 +50,10 @@ public function test_can_set_a_class(): void
5050
self::assertSame('2025-03-09 07:29:00', $dateTimeImmutable->format('Y-m-d H:i:s'));
5151
}
5252

53-
/** @dataProvider nonInstantiableClassStringsDataProvider */
53+
/**
54+
* @dataProvider nonInstantiableClassStringsDataProvider
55+
* @param class-string $class
56+
*/
5457
public function test_it_throws_an_exception_when_the_class_is_not_instantiable(
5558
string $class
5659
): void {
@@ -116,7 +119,7 @@ public function test_can_get_a_class_with_a_non_builtin_constructor_parameter():
116119

117120
self::assertInstanceOf(
118121
ExampleClassWithAnNonBuiltinConstructorParameter::class,
119-
$container->get(ExampleClassWithAnNonBuiltinConstructorParameter::class)
122+
@$container->get(ExampleClassWithAnNonBuiltinConstructorParameter::class)
120123
);
121124
}
122125

@@ -136,6 +139,7 @@ public function test_it_throws_an_exception_when_the_class_has_a_union_type_hint
136139
$container->get(ExampleClassWithUnionTypeHint::class);
137140
}
138141

142+
/** @return array{0: class-string}[] */
139143
public static function nonInstantiableClassStringsDataProvider(): array
140144
{
141145
return [
@@ -164,8 +168,10 @@ public function __construct()
164168

165169
final class ExampleClassWithoutConstructorParameterTypeHint
166170
{
171+
/** @var mixed */
167172
public $parameter;
168173

174+
/** @param mixed $parameter */
169175
public function __construct($parameter)
170176
{
171177
$this->parameter = $parameter;
@@ -174,17 +180,23 @@ public function __construct($parameter)
174180

175181
final class ExampleClassWithBuiltinConstructorParameter
176182
{
183+
/** @var int */
184+
public $parameter;
185+
177186
public function __construct(int $parameter)
178187
{
179-
// No parameters
188+
$this->parameter = $parameter;
180189
}
181190
}
182191

183192
final class ExampleClassWithAnNonBuiltinConstructorParameter
184193
{
194+
/** @var DateTimeImmutable */
195+
public $dateTime;
196+
185197
public function __construct(DateTimeImmutable $dateTimeImmutable)
186198
{
187-
// No parameters
199+
$this->dateTime = $dateTimeImmutable;
188200
}
189201
}
190202

0 commit comments

Comments
 (0)