When using ??= on an implementation of ArrayAccess whose offsetGet() can return null for nonexistent offsets, I'm getting a false-positive PossiblyNullArgument:
// Psalm infers $foo as Foo|null even though that's impossible
$foo = ($map['foo'] ??= new Foo());
The offsetGet() method is not called at all when ??= is used so it is impossible for it to influence the call to offsetSet() or the result of the ??= operator:
When using
??=
on an implementation ofArrayAccess
whoseoffsetGet()
can returnnull
for nonexistent offsets, I'm getting a false-positivePossiblyNullArgument
:https://psalm.dev/r/f82e852479
The
offsetGet()
method is not called at all when??=
is used so it is impossible for it to influence the call tooffsetSet()
or the result of the??=
operator:https://3v4l.org/vQqLV