Skip to content

Commit 543d405

Browse files
committed
fix: Failing PHPStan
1 parent ee52703 commit 543d405

File tree

10 files changed

+26
-7
lines changed

10 files changed

+26
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
],
1111
"require": {
1212
"php": ">=8.2",
13-
"good-php/reflection": "dev-update-deps",
13+
"good-php/reflection": "^2.0",
1414
"illuminate/support": "^10.0 || ^11.0 || ^12.0"
1515
},
1616
"require-dev": {

src/TypeAdapter/Json/FromPrimitiveJsonTypeAdapterFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
*/
1616
final class FromPrimitiveJsonTypeAdapterFactory implements TypeAdapterFactory
1717
{
18+
/**
19+
* @return JsonTypeAdapter<mixed>|null
20+
*/
1821
public function create(string $typeAdapterType, Type $type, Attributes $attributes, Serializer $serializer): ?JsonTypeAdapter
1922
{
2023
if ($typeAdapterType !== JsonTypeAdapter::class) {

src/TypeAdapter/Primitive/BuiltIn/ArrayMapper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ final class ArrayMapper
1818
/**
1919
* @template T
2020
*
21-
* @param list<T> $value
22-
* @param NamedType $type
21+
* @param array<mixed, T> $value
22+
* @param NamedType $type
2323
*
24-
* @return list<mixed>
24+
* @return array<mixed, mixed>|stdClass
2525
*/
2626
#[MapTo(PrimitiveTypeAdapter::class)]
2727
public function to(array $value, Type $type, Serializer $serializer): array|stdClass
@@ -49,10 +49,10 @@ public function to(array $value, Type $type, Serializer $serializer): array|stdC
4949
}
5050

5151
/**
52-
* @param list<mixed> $value
53-
* @param NamedType $type
52+
* @param array<mixed, mixed> $value
53+
* @param NamedType $type
5454
*
55-
* @return list<mixed>
55+
* @return array<mixed, mixed>
5656
*/
5757
#[MapFrom(PrimitiveTypeAdapter::class)]
5858
public function from(array $value, Type $type, Serializer $serializer): array

src/TypeAdapter/Primitive/BuiltIn/BackedEnumMapper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function to(BackedEnum $value): string|int
2525
#[MapFrom(PrimitiveTypeAdapter::class, new BaseTypeAcceptedByAcceptanceStrategy(BackedEnum::class))]
2626
public function from(string|int $value, Type $type): BackedEnum
2727
{
28+
/** @var class-string<BackedEnum> $enumClass */
2829
$enumClass = $type->name;
2930
$enum = $enumClass::tryFrom($value);
3031

src/TypeAdapter/Primitive/BuiltIn/Nullable/NullableTypeAdapterFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
*/
1515
class NullableTypeAdapterFactory implements TypeAdapterFactory
1616
{
17+
/**
18+
* @return NullableTypeAdapter<mixed>|null
19+
*/
1720
public function create(string $typeAdapterType, Type $type, Attributes $attributes, Serializer $serializer): ?NullableTypeAdapter
1821
{
1922
if ($typeAdapterType !== PrimitiveTypeAdapter::class || !$type instanceof NullableType) {

src/TypeAdapter/Primitive/ClassProperties/ClassPropertiesPrimitiveTypeAdapterFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public function __construct(
2525
private readonly BoundClassPropertyFactory $boundClassPropertyFactory,
2626
) {}
2727

28+
/**
29+
* @return ClassPropertiesPrimitiveTypeAdapter<object>|null
30+
*/
2831
public function create(string $typeAdapterType, Type $type, Attributes $attributes, Serializer $serializer): ?ClassPropertiesPrimitiveTypeAdapter
2932
{
3033
if ($typeAdapterType !== PrimitiveTypeAdapter::class || !$type instanceof NamedType) {

src/TypeAdapter/Primitive/MapperMethods/TypeAdapter/MapperMethodsPrimitiveTypeAdapterFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public function __construct(
2626
Assert::true($this->toMappers || $this->fromMappers);
2727
}
2828

29+
/**
30+
* @return MapperMethodsPrimitiveTypeAdapter<mixed>|null
31+
*/
2932
public function create(string $typeAdapterType, Type $type, Attributes $attributes, Serializer $serializer): ?MapperMethodsPrimitiveTypeAdapter
3033
{
3134
if ($typeAdapterType !== PrimitiveTypeAdapter::class || !$type instanceof NamedType) {

src/TypeAdapter/Primitive/PhpStandard/ValueEnumMapper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function to(ValueEnum $value): string|int
3939
#[MapFrom(PrimitiveTypeAdapter::class, new BaseTypeAcceptedByAcceptanceStrategy(ValueEnum::class))]
4040
public function from(string|int $value, Type $type): ValueEnum
4141
{
42+
/** @var class-string<ValueEnum<string|int>> $enumClass */
4243
$enumClass = $type->name;
4344

4445
try {

src/TypeAdapter/Primitive/Polymorphic/ClassPolymorphicTypeAdapterFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public static function for(string $parentClassName, string $serializedTypeNameFi
3535
return new ClassPolymorphicTypeAdapterFactoryBuilder($parentClassName, $serializedTypeNameField);
3636
}
3737

38+
/**
39+
* @return PolymorphicTypeAdapter<object>|null
40+
*/
3841
public function create(string $typeAdapterType, Type $type, Attributes $attributes, Serializer $serializer): ?PolymorphicTypeAdapter
3942
{
4043
if (

src/TypeAdapter/TypeAdapterFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ interface TypeAdapterFactory
1414
{
1515
/**
1616
* @param class-string<TypeAdapter<mixed, mixed>> $typeAdapterType
17+
*
18+
* @return TypeAdapter<mixed, mixed>|null
1719
*/
1820
public function create(string $typeAdapterType, Type $type, Attributes $attributes, Serializer $serializer): ?TypeAdapter;
1921
}

0 commit comments

Comments
 (0)