phpstan icon indicating copy to clipboard operation
phpstan copied to clipboard

Array shape is forgotten by adding some conditionals.

Open bendavies opened this issue 3 years ago • 3 comments
trafficstars

Bug report

It seems phpstan is "forgetting" the shape of an array by just adding 2 conditional statements.

Code snippet that reproduces the problem

https://phpstan.org/r/3412d834-a20f-4968-aeae-06b6b07e4463

Expected output

Array shape is not forgotten.

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

1.8.5 caught some more issues to fix in our product!

bendavies avatar Sep 16 '22 10:09 bendavies

Too me it's a duplicate of https://github.com/phpstan/phpstan/issues/7963 and https://github.com/phpstan/phpstan/issues/8004

Since the array_shape is very complex, it is simplified by phpstan.

VincentLanglet avatar Sep 18 '22 17:09 VincentLanglet

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

@@ @@
  5: Dumped type: int
-10: Dumped type: int|string|null
+10: Dumped type: int
Full report
Line Error
5 Dumped type: int
10 Dumped type: int

phpstan-bot avatar Sep 19 '22 17:09 phpstan-bot

Seems like it's solved by https://github.com/phpstan/phpstan-src/compare/43d365200bd6b11e9ab690049ffce2bcc46d9e86...bd57fc59f4737188ce750f607f42d85e6d4aec37

Do you want to add a regression test @ondrejmirtes @rvanvelzen ? (I can do it if the test if wanted)

VincentLanglet avatar Sep 19 '22 18:09 VincentLanglet

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[bot] avatar Oct 24 '22 00:10 github-actions[bot]