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

Passing some combinations of union types to parameter types messes up the closure param type inference #5675

Closed
canvural opened this issue Sep 22, 2021 · 8 comments
Labels
Milestone

Comments

@canvural
Copy link
Contributor

canvural commented Sep 22, 2021

Bug report

Passing some combinations of union types seems to break the closure param type inference.

For example, @param (\Closure(static<T>): void)|array<array-key, int> $column or @param (\Closure(Hello<T>): void)|array<array-key, int> $column works.
But * @param (\Closure(static<T>): void)|string|array<int, mixed> $column or @param (\Closure(static<T>): void)|array<array-key, int>|Bar $column does not work.

Code snippet that reproduces the problem

https://phpstan.org/r/24e0e585-9288-4b2a-95e9-8317dfd53426

Expected output

No error

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

@ondrejmirtes
Copy link
Member

Hi, static<T> is a weird one and not totally supported, can you try to reproduce the problem without it? Thanks!

@canvural
Copy link
Contributor Author

Same error with Hello<T>: https://phpstan.org/r/6cf48614-02c0-4a32-87ce-fd500849cb4e

@phpstan-bot
Copy link
Contributor

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

@@ @@
-23: Expected type Hello<string>, actual: Hello
+No errors

@phpstan-bot
Copy link
Contributor

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

@@ @@
-23: Expected type Hello<string>, actual: Hello
+No errors

@canvural
Copy link
Contributor Author

Hi @ondrejmirtes ,

This looks like it's fixed for both of my examples. Maybe because of phpstan/phpstan-src@a483c11 ?

Can we close this?

@ondrejmirtes
Copy link
Member

Weird, the bot commented on this in October already, not sure why :) Closing this, will add a regression test later.

@canvural
Copy link
Contributor Author

Weird, the bot commented on this in October already, not sure why :) Closing this, will add a regression test later.

I think there was an issue with the bot at that time. It commented on multiple issues that they are resolved.

@github-actions
Copy link

github-actions bot commented Apr 1, 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 Apr 1, 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