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

Inference of array unpacking results in false negative #2833

Closed
Majkl578 opened this issue Jan 8, 2020 · 3 comments
Closed

Inference of array unpacking results in false negative #2833

Majkl578 opened this issue Jan 8, 2020 · 3 comments

Comments

@Majkl578
Copy link
Contributor

@Majkl578 Majkl578 commented Jan 8, 2020

Bug report

Unpacking inside arrays is possible since PHP 7.4. PHPStan doesn't seem to infer unpacked types properly.

Code snippet that reproduces the problem

https://phpstan.org/r/c80a279b-2ac6-401b-aadd-eae0847a8495

Expected output

The snippet should complain about (string|int)[] being returned while int[] is expected but reports no errors instead.

@ondrejmirtes

This comment has been minimized.

Copy link
Member

@ondrejmirtes ondrejmirtes commented Jan 8, 2020

Wrong playground link

@Majkl578

This comment has been minimized.

Copy link
Contributor Author

@Majkl578 Majkl578 commented Jan 8, 2020

Fixed, there was > at the end.

@muglug

This comment has been minimized.

Copy link
Contributor

@muglug muglug commented Jan 8, 2020

@Majkl578 your code was buggy, with the correct calls the code errors appropriately: https://phpstan.org/r/8ce206dd-266c-45b0-bcc8-42d812b4b0cd

@Majkl578 Majkl578 closed this Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.