Bug report
It seems that checking if an array key isset can affect the type of a variable outside the if block, even if that block is empty. This was noticed while checking an array where one key is a template, and the other is optional.
The intention was to construct an object from a deeply nested array, where the outer keys are common between multiple classes.
Code snippet that reproduces the problem
https://phpstan.org/r/74d76565-8cf6-4da7-ab53-59f289d04097
Expected output
No errors reported.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan was useful while refactoring some data structures. By checking types, it helped ensure no files were forgotten.
Bug report
It seems that checking if an array key
issetcan affect the type of a variable outside theifblock, even if that block is empty. This was noticed while checking an array where one key is a template, and the other is optional.The intention was to construct an object from a deeply nested array, where the outer keys are common between multiple classes.
Code snippet that reproduces the problem
https://phpstan.org/r/74d76565-8cf6-4da7-ab53-59f289d04097
Expected output
No errors reported.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan was useful while refactoring some data structures. By checking types, it helped ensure no files were forgotten.