Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

(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
ondrejmirtes merged 2 commits into phpstan:master from lucassabreu:master
Oct 30, 2020

Conversation

Copy link
Contributor

@lucassabreu lucassabreu commented Oct 29, 2020

No description provided.

Copy link
Member

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

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.

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 :)

Copy link
Member

Thank you!

lucassabreu reacted with thumbs up emoji

Copy link
Member

Tagged as 0.12.11.

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.

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.

Copy link
Contributor

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@ondrejmirtes ondrejmirtes Awaiting requested review from ondrejmirtes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /