Skip to content

Update DenormalizerInterface::denormalize #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2022

Conversation

VincentLanglet
Copy link
Contributor

Hi @ondrejmirtes

The stub from phpstan-symfony is restricting the return type to object|array, but there is no restriction in the interface from Symfony ; cf https://github.com/symfony/Serializer/blob/6.1/Normalizer/DenormalizerInterface.php.

So I changed the return type to mixed like the one from Symfony.

@ondrejmirtes
Copy link
Member

The original stub was added here: https://github.com/phpstan/phpstan-symfony/pull/110/files#diff-d6e0c3f17a9176b0a39dd84f85be359c3c3040b510989168b8ada8c3dfd9e050R12

//cc @lucassabreu what do you think is correct here? Thank you.

@VincentLanglet
Copy link
Contributor Author

For more context @lucassabreu, I have a friend returning other thing than object/array in this method, and everything working fine.
So since even the phpdoc from symfony is not restricting to object/array, I don't think we should here.

@lucassabreu
Copy link
Contributor

@ondrejmirtes i think it makes sense to return mixed, Symfony kind of accepts scalar types, and there is no restriction by what I understand.

I think my logic at the time was that you didn't need a Denormalizer to convert mixed to scalars or resources, but I don't think it will make the stub less effective to allow mixed.

cc: @VincentLanglet

@ondrejmirtes ondrejmirtes merged commit 4bdffcf into phpstan:master Mar 24, 2022
@ondrejmirtes
Copy link
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants