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

Template type bound to array vs array shapes #6568

Closed
arnaud-lb opened this issue Feb 5, 2022 · 5 comments
Closed

Template type bound to array vs array shapes #6568

arnaud-lb opened this issue Feb 5, 2022 · 5 comments

Comments

@arnaud-lb
Copy link
Contributor

Bug report

In the following code snippet, it is possible to return an array that is not compatible with the resolved type

Code snippet that reproduces the problem

https://phpstan.org/r/9effa16d-1197-45d0-ae20-3df328f43115

Expected output

Function test() should return T of array but returns array.
@arnaud-lb arnaud-lb changed the title Generics vs array shapes Template type bound to array vs array shapes Feb 5, 2022
@ondrejmirtes ondrejmirtes added this to the Generics milestone Feb 5, 2022
@mvorisek
Copy link
Contributor

mvorisek commented Feb 7, 2022

related to #6588

@phpstan-bot
Copy link
Contributor

@arnaud-lb After the latest push in 1.10.x, PHPStan now reports different result with your code snippet:

@@ @@
+10: Function test() should return T of array but returns array<mixed, mixed>.
 17: Dumped type: array{foo: 1}
Full report
Line Error
10 Function test() should return T of array but returns array<mixed, mixed>.
17 Dumped type: array{foo: 1}

@arnaud-lb
Copy link
Contributor Author

This is fixed, according to the bot. Thank you!

@ondrejmirtes
Copy link
Member

Yeah, it nicely surprised me 😊

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

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

No branches or pull requests

4 participants