diff --git a/composer.json b/composer.json index 9307d9e..587c975 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "symfony/console": "*", "symfony/messenger": "^4.2 || ^5.0", "symfony/security-guard": "^4.0 || ^5.0", + "symfony/serializer": "^4.0 || ^5.0", "symfony/validator": "*", "twig/twig": "^2.10 || ^3.0", "weirdan/codeception-psalm-module": "~0.9" diff --git a/src/Stubs/common/DenormalizerInterface.stubphp b/src/Stubs/common/DenormalizerInterface.stubphp index 55a8ac1..e559b75 100644 --- a/src/Stubs/common/DenormalizerInterface.stubphp +++ b/src/Stubs/common/DenormalizerInterface.stubphp @@ -7,6 +7,7 @@ interface DenormalizerInterface /** * @template TObject of object * @template TType of string|class-string + * @psalm-param mixed $data * @psalm-param TType $type * @psalm-return (TType is class-string ? TObject : mixed) */ diff --git a/src/Stubs/common/SerializerInterface.stubphp b/src/Stubs/common/SerializerInterface.stubphp index 3739e25..a2f1aa1 100644 --- a/src/Stubs/common/SerializerInterface.stubphp +++ b/src/Stubs/common/SerializerInterface.stubphp @@ -7,6 +7,7 @@ interface SerializerInterface /** * @template TObject of object * @template TType of string|class-string + * @psalm-param mixed $data * @psalm-param TType $type * @psalm-return (TType is class-string ? TObject : mixed) */ diff --git a/tests/acceptance/acceptance/DenormalizerInterface.feature b/tests/acceptance/acceptance/DenormalizerInterface.feature index aa03d6a..4fdeb17 100644 --- a/tests/acceptance/acceptance/DenormalizerInterface.feature +++ b/tests/acceptance/acceptance/DenormalizerInterface.feature @@ -22,7 +22,9 @@ Feature: Denormalizer interface Given I have the following code """ denormalize([], stdClass::class); /** @psalm-trace $result */ @@ -38,7 +40,9 @@ Feature: Denormalizer interface Given I have the following code """ denormalize([], 'stdClass[]'); /** @psalm-trace $result */ @@ -50,3 +54,25 @@ Feature: Denormalizer interface | MixedAssignment | Unable to determine the type that $result is being assigned to | | Trace | $result: mixed | And I see no other errors + + Scenario: Psalm does not complain about the missing $data parameter type in the denormalizer implementation + Given I have the following code + """ + deserialize([], stdClass::class, 'json'); /** @psalm-trace $result */ @@ -38,7 +40,9 @@ Feature: Serializer interface Given I have the following code """ deserialize([], 'stdClass[]', 'json'); /** @psalm-trace $result */ @@ -50,3 +54,25 @@ Feature: Serializer interface | MixedAssignment | Unable to determine the type that $result is being assigned to | | Trace | $result: mixed | And I see no other errors + + Scenario: Psalm does not complain about the missing $data parameter type in the serializer implementation + Given I have the following code + """ +