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
Isset check on array is loosing generic of the values #7511
Comments
This works with
but not
It might help to know what's the issue. |
@VincentLanglet After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
24: Dumped type: T of PositionEntityInterface&TgEntityInterface (method HelloWorld::computeForFrontByPosition(), parameter)
30: Dumped type: T of PositionEntityInterface&TgEntityInterface (method HelloWorld::computeForFrontByPosition(), argument)
33: Dumped type: T of PositionEntityInterface&TgEntityInterface (method HelloWorld::computeForFrontByPosition(), argument)
-34: Dumped type: PositionEntityInterface&TgEntityInterface
-36: Dumped type: PositionEntityInterface&TgEntityInterface
-42: Method HelloWorld::computeForFrontByPosition() should return array<T of PositionEntityInterface&TgEntityInterface> but returns array<PositionEntityInterface&TgEntityInterface>.
+34: Dumped type: T of PositionEntityInterface&TgEntityInterface (method HelloWorld::computeForFrontByPosition(), parameter)
+36: Dumped type: T of PositionEntityInterface&TgEntityInterface (method HelloWorld::computeForFrontByPosition(), parameter) Full report
|
@VincentLanglet After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
24: Dumped type: array<T of PositionEntityInterface&TgEntityInterface (method HelloWorld::computeForFrontByPosition(), parameter)>
29: Dumped type: T of PositionEntityInterface&TgEntityInterface (method HelloWorld::computeForFrontByPosition(), parameter)
-31: Dumped type: PositionEntityInterface&TgEntityInterface
+31: Dumped type: T of PositionEntityInterface&TgEntityInterface (method HelloWorld::computeForFrontByPosition(), parameter)
34: Dumped type: array<T of PositionEntityInterface&TgEntityInterface (method HelloWorld::computeForFrontByPosition(), parameter)> Full report
|
Seems like you solved this issue @ondrejmirtes so I added a non-regression test phpstan/phpstan-src#1556 |
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
Follow up of #7460
and #7500
It seems like when using
array<T of Foo>
and usingisset()
then accesing a value, the value is just considered as Foo.Code snippet that reproduces the problem
Original issue:
https://phpstan.org/r/cfa53647-37aa-400e-8c4d-27ff902a807d
But this can be simplified to https://phpstan.org/r/0fc99af2-13fd-4c7f-bd43-06408b41e56f
The text was updated successfully, but these errors were encountered: