Bug report
Getting a nullCoalesce.property error on statements like these, where $array is array<string, list<SomeDTO>>:
$value = $array['foo'][0]->value->value ?? null;
The 'foo' and 0 offsets might not exist, so the ?? usage is valid and should not be reported. The fact that ValueObject::$value is not nullable is not relevant in this case.
This seems to only happen when chained property accesses are involved. Statements like $array['someKey'][0]->value ?? null don't produce this false-positive.
Code snippet that reproduces the problem
https://phpstan.org/r/e60e7f65-17e5-41e8-b070-3d56d2d65946
Expected output
No error
Did PHPStan help you today? Did it make you happy in any way?
No response
Bug report
Getting a
nullCoalesce.propertyerror on statements like these, where$arrayisarray<string, list<SomeDTO>>:The
'foo'and0offsets might not exist, so the??usage is valid and should not be reported. The fact thatValueObject::$valueis not nullable is not relevant in this case.This seems to only happen when chained property accesses are involved. Statements like
$array['someKey'][0]->value ?? nulldon't produce this false-positive.Code snippet that reproduces the problem
https://phpstan.org/r/e60e7f65-17e5-41e8-b070-3d56d2d65946
Expected output
No error
Did PHPStan help you today? Did it make you happy in any way?
No response