Skip to content
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

@param Generator<mixed> doesn't accept anything but a generator that actually yield mixed type #6464

Closed
e-zannelli opened this issue Jan 26, 2022 · 3 comments
Labels
Milestone

Comments

@e-zannelli
Copy link

Bug report

Like with an iterable<mixed> I expect a parameter typed Generator<mixed> to accept a generator that has been inferred to be a \Generator<anyType>.

But in level 9, phpstan complains that the given type do not match the expected one, except if the inferred yielded type is actually mixed.

Code snippet that reproduces the problem

https://phpstan.org/r/ce1f6000-702b-4562-b81b-44dc3f08444a

Expected output

No error.

Did PHPStan help you today? Did it make you happy in any way?

PHPStan helps me every work day 😉 It's great. Thanks

@e-zannelli e-zannelli changed the title @param Generator<mixed> doesn't accept anything a generator that actually yield mixed type @param Generator<mixed> doesn't accept anything but a generator that actually yield mixed type Jan 26, 2022
@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Jan 26, 2022
@phpstan-bot
Copy link
Contributor

@e-zannelli After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-10: Parameter #1 $g of method Foo::foo() expects Generator<int, mixed, mixed, void>, Generator<int, string, mixed, void> given.
+No errors

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@9f12f0f

ondrejmirtes added a commit to phpstan/phpstan-src that referenced this issue Feb 28, 2022
@github-actions
Copy link

github-actions bot commented Mar 6, 2022

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 Mar 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants