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

Regarding the analysis of the return value of range() #9573

Closed
keibass opened this issue Jul 5, 2023 · 4 comments
Closed

Regarding the analysis of the return value of range() #9573

keibass opened this issue Jul 5, 2023 · 4 comments
Labels
Milestone

Comments

@keibass
Copy link

keibass commented Jul 5, 2023

Bug report

When attempting to assign the return value of range() to a property marked as list, a type mismatch error is reported.
However, $count is confirmed to be positive-int, and the return value of range() should definitely be list.

#9572

Code snippet that reproduces the problem

https://phpstan.org/r/133e0fc4-a35e-4546-bbc0-d49efe4a70c3

Expected output

No error

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

No response

@GMQS
Copy link

GMQS commented Jul 5, 2023

As additional information, the same phenomenon did not occur with local variables. It is only confirmed to happen with properties.

@phpstan-bot
Copy link
Contributor

@keibass After the latest push in 1.11.x, PHPStan now reports different result with your code snippet:

@@ @@
-12: Property MyClass::$array (array<int, int<1, max>>) does not accept array<int, int>.
+No errors

@ondrejmirtes
Copy link
Member

Fixed phpstan/phpstan-src#2792

Copy link

github-actions bot commented Feb 7, 2024

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 7, 2024
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

4 participants