Skip to content

(feat): add stubs for symfony/serializer interfaces #110

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 2 commits into from
Oct 30, 2020

Conversation

lucassabreu
Copy link
Contributor

No description provided.

@ondrejmirtes
Copy link
Member

Hi, there aren't any generics in these stubs, what do they actually solve?

@lucassabreu
Copy link
Contributor Author

hi @ondrejmirtes, today there isn't any generics on these classes.

the pr is mostly to set a element type for the $context array on these classes, phpstan is requiring a type for it on higher levels. but in some situations these parameter is not used, so add these stubs would mean we don't have to set it on all classes.

we could say the NormalizerInterface could be use a generic type for the return of the normalize method, but it can set it in the implementation.

@ondrejmirtes
Copy link
Member

The build failures need fixing :)

------ ------------------------------------------------------------------- 

  Line   stubs/ContextAwareDenormalizerInterface.stub                       

 ------ ------------------------------------------------------------------- 

         Reflection error:                                                  

         Symfony\Component\Serializer\Normalizer\DenormalizerInterface not  

         found.                                                             

 ------ ------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------- 

  Line   stubs/DenormalizableInterface.stub                                     

 ------ ----------------------------------------------------------------------- 

  15     Parameter $denormalizer of method                                      

         Symfony\Component\Serializer\Normalizer\DenormalizableInterface::deno  

         rmalize() has invalid typehint type                                    

         Symfony\Component\Serializer\Normalizer\DenormalizerInterface.         

  15     Parameter $denormalizer of method                                      

         Symfony\Component\Serializer\Normalizer\DenormalizableInterface::deno  

         rmalize() has invalid typehint type                                    

         Symfony\Component\Serializer\Normalizer\DenormalizerInterface.         

 ------ ----------------------------------------------------------------------- 

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, one last round and we can merge this :)

@ondrejmirtes
Copy link
Member

Thank you!

@ondrejmirtes
Copy link
Member

Tagged as 0.12.11.

@ossinkine
Copy link
Contributor

Hey @lucassabreu, why these stubs are needed? Symfony already has types in these interfaces and more accurate, for example EncoderInterface::encode returns only string. This produces false positives.

@mhujer
Copy link
Contributor

mhujer commented Mar 24, 2021

@ossinkine it seems that the types were fixed in Symfony (symfony/symfony#39451) after this PR was merged.

@ossinkine
Copy link
Contributor

@mhujer Thank you but this does not explain why these stubs were created.

@lucassabreu
Copy link
Contributor Author

Hey @lucassabreu, why these stubs are needed? Symfony already has types in these interfaces and more accurate, for example EncoderInterface::encode returns only string. This produces false positives.

Hi @ossinkine as mhujer said these interfaces didn't have the types for return and parameters, and we had to set them on every implementation before to satisfy higher levels on phpstan, but this types were ways the same and didn't make much sense to set them on my classes that were just implementing these interfaces.

the types on this pr are the ones I thought were right at the time.

if symfony has them set now i think that we can remove these stubs now for the new symfony versions.

@ossinkine ossinkine mentioned this pull request Apr 12, 2021
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.

4 participants