Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cover every node kind checked by NullCoalesceRule::containsAssign()
Only the plain `Assign` branch was exercised so far. Add one right side
per remaining node kind, each of them inferred as `null` so it reaches
the check: `=&`, a nested `+=`, and `++`/`--` in an array offset of an
`array<int, null>`.

Removing any single `instanceof` clause makes exactly one of these cases
report the false positive again.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
  • Loading branch information
2 people authored and staabm committed Sep 12, 2026
commit 82b2c004f87f08a910dea9de8271f49d7961c5a1
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,40 @@ function nullPropertyOnRightSide(Foo $foo, Foo $bar): ?string
{
return $foo->stringOrNull ?? $bar->alwaysNull;
}

function assignRefOnRightSide(Foo $foo): ?string
{
$null = null;

return $foo->stringOrNull ?? $ref = &$null;
}

/** @param array<int, null> $nulls */
function assignOpInOffsetOnRightSide(Foo $foo, array $nulls, int $i): ?string
{
return $foo->stringOrNull ?? $nulls[$i += 1];
}

/** @param array<int, null> $nulls */
function postIncOnRightSide(Foo $foo, array $nulls, int $i): ?string
{
return $foo->stringOrNull ?? $nulls[$i++];
}

/** @param array<int, null> $nulls */
function preIncOnRightSide(Foo $foo, array $nulls, int $i): ?string
{
return $foo->stringOrNull ?? $nulls[++$i];
}

/** @param array<int, null> $nulls */
function postDecOnRightSide(Foo $foo, array $nulls, int $i): ?string
{
return $foo->stringOrNull ?? $nulls[$i--];
}

/** @param array<int, null> $nulls */
function preDecOnRightSide(Foo $foo, array $nulls, int $i): ?string
{
return $foo->stringOrNull ?? $nulls[--$i];
}