Description
Bug report
PHPStan evaluates []
as array{}
, so a possibly empty array compared against it will be reported as false.
Code snippet that reproduces the problem
Strict comparison using === between array and array{} will always evaluate to false.
https://phpstan.org/r/d426c53a-8ada-4f53-a719-3ca296c3459d
If adding a docblock on the possible array shape, a similar error occurs.
Strict comparison using === between array{} and array{} will always evaluate to false.
https://phpstan.org/r/348c3626-bfe6-4f25-9085-3684be966060
Please note that the first error only occurs if treatPhpDocTypesAsCertain
is set to false
. There are no errors if set to true
.
There's a completely different error Else branch is unreachable...
for the second scenario, but that is already reported.
Expected output
The code should be valid.
Did PHPStan help you today? Did it make you happy in any way?
Yes, definitely.