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
\Ds\Map::get() false positive with numeric-string #5592
Comments
@enumag After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-9: Function mapGet() should return string&numeric but returns string.
+7: Function mapGet() should return string but return statement is missing. Full report
|
@enumag After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-9: Function mapGet() should return string&numeric but returns string.
+9: Function mapGet() should return numeric-string but returns string. Full report
|
I recently ran into a very similar thing (probably caused by the same root issue) that happens with https://phpstan.org/r/8718979a-6773-4bf8-b42d-b2c9dcae0d3e Notably, in both cases the issue does not occur if |
Upon examining The problem really has nothing to do with It looks like perhaps the issue actually has something to do with generics? |
This is probably the same issue as #6653 - the type is generalized for mixed bounds. For the last example, if you were to bound |
Closes phpstan/phpstan#8166 Closes phpstan/phpstan#8127 Closes phpstan/phpstan#7944 Closes phpstan/phpstan#7283 Closes phpstan/phpstan#6653 Closes phpstan/phpstan#6196 Closes phpstan/phpstan#9084 Closes phpstan/phpstan#8683 Closes phpstan/phpstan#8074 Closes phpstan/phpstan#7984 Closes phpstan/phpstan#7301 Closes phpstan/phpstan#7087 Closes phpstan/phpstan#5594 Closes phpstan/phpstan#5592 Closes phpstan/phpstan#9472 Closes phpstan/phpstan#9764 Closes phpstan/phpstan#10092
Closes phpstan/phpstan#8166 Closes phpstan/phpstan#8127 Closes phpstan/phpstan#7944 Closes phpstan/phpstan#7283 Closes phpstan/phpstan#6653 Closes phpstan/phpstan#6196 Closes phpstan/phpstan#9084 Closes phpstan/phpstan#8683 Closes phpstan/phpstan#8074 Closes phpstan/phpstan#7984 Closes phpstan/phpstan#7301 Closes phpstan/phpstan#7087 Closes phpstan/phpstan#5594 Closes phpstan/phpstan#5592 Closes phpstan/phpstan#9472 Closes phpstan/phpstan#9764 Closes phpstan/phpstan#10092
Closes phpstan/phpstan#8166 Closes phpstan/phpstan#8127 Closes phpstan/phpstan#7944 Closes phpstan/phpstan#7283 Closes phpstan/phpstan#6653 Closes phpstan/phpstan#6196 Closes phpstan/phpstan#9084 Closes phpstan/phpstan#8683 Closes phpstan/phpstan#8074 Closes phpstan/phpstan#7984 Closes phpstan/phpstan#7301 Closes phpstan/phpstan#7087 Closes phpstan/phpstan#5594 Closes phpstan/phpstan#5592 Closes phpstan/phpstan#9472 Closes phpstan/phpstan#9764 Closes phpstan/phpstan#10092
Last night I came up with the idea that we mostly shouldn't generalize the generic type variables, except when they're in object generics, like Here's the resulting PR: phpstan/phpstan-src#2818 We can't do this for objects, because I want The new behaviour now only applies to bleeding edge (https://phpstan.org/blog/what-is-bleeding-edge) so definitely enable it to get the taste of the future 👍 |
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. |
Bug report
Most likely a bug somewhere in DsMapDynamicReturnTypeExtension or possibly in ParametersAcceptorSelector but so far I was unable to figure it out.
Code snippet that reproduces the problem
https://phpstan.org/r/9c9c6dd3-0bb0-4008-90e7-25f37c3cd687
Expected output
no error
The text was updated successfully, but these errors were encountered: