Skip to content

False positive with Symfony Messenger #43

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

Closed
enumag opened this issue Mar 26, 2019 · 2 comments
Closed

False positive with Symfony Messenger #43

enumag opened this issue Mar 26, 2019 · 2 comments

Comments

@enumag
Copy link
Contributor

enumag commented Mar 26, 2019

Symfony\Component\Messenger\Envelope::all() returns a different type based on whether or not an argument was passed to it. Currently PHPStan doesn't know that which results in errors like this:

Parameter #1 ... of method ... expects array<array<Symfony\Component\Messenger\Stamp\StampInterface>>, array<array<Symfony\Component\Messenger\Stamp\StampInterface>|Symfony\Component\Messenger\Stamp\StampInterface> given.

I'd send PR but I'm not sure how cases like these should be solved in PHPStan. If you can give me an advice how to do it, I'll send the PR.

@ondrejmirtes
Copy link
Member

You need to create a dynamic return type extension similar to this one, but maybe even easier: https://github.com/phpstan/phpstan-symfony/blob/master/src/Type/Symfony/HeaderBagDynamicReturnTypeExtension.php

@github-actions
Copy link

github-actions bot commented May 1, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants