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

Generic template class-string inferred as string #6505

Closed
snapshotpl opened this issue Feb 1, 2022 · 3 comments · Fixed by phpstan/phpstan-src#1038
Closed

Generic template class-string inferred as string #6505

snapshotpl opened this issue Feb 1, 2022 · 3 comments · Fixed by phpstan/phpstan-src#1038
Labels
Milestone

Comments

@snapshotpl
Copy link

Code snippet that reproduces the problem

https://phpstan.org/r/7ce837b3-a890-4c9e-9d27-94c06b601b0a

Expected output

Dumped type: array<class-string<stdClass>>
@ondrejmirtes ondrejmirtes added this to the Generics milestone Feb 1, 2022
@arnaud-lb
Copy link
Contributor

arnaud-lb commented Feb 4, 2022

Shorter snippet: https://phpstan.org/r/a8c21b7f-a453-42cb-b231-1935203770f1

This is the result of generalization after type inference. class-string is being generalized to string unless T is bound to string.

@zlodes
Copy link

zlodes commented Feb 10, 2022

I faced this issue now.

I have cleaned my own example using of Laravel 9.0 Collections and values containing class-string.
Here is an example: https://phpstan.org/r/e08e3a67-97cf-4d7e-83f9-a3fbfbd97173

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

Successfully merging a pull request may close this issue.

4 participants