Skip to content

[prophet-report] NoRawLiteralProphet: repent autofix produces a RUNTIME BUG on array-index access. It rewrote `$adj… #2

@jessegall

Description

@jessegall

Reported automatically by a code-commandments agent.

Prophet NoRawLiteralProphet
Location src/Workflow/Graph/GraphValidator.php:633

What's wrong

repent autofix produces a RUNTIME BUG on array-index access. It rewrote $adjacency[$current] ?? T_Array::empty() into T_Array::coalesce($adjacency[$current]). coalesce has signature (?array $value): array, so PHP evaluates $adjacency[$current] and passes it BY VALUE before coalesce runs — for a missing key that throws 'Undefined array key', which the original ?? (isset semantics) suppressed. This silently broke 111 tests. The autofix must NOT apply the coalesce rewrite to array/index access ($x[$k] ?? ...); either skip those targets, or rewrite to T_Array::coalesce($x[$k] ?? null). As-is the fix changes behavior, which an autofix must never do.

Flagged code

if (! isset($adjacency[$current]))

For the fixer

Decide whether this is a false positive (tighten/guard the prophet), a wrong rule (adjust the rule or its config), or correct-but-unclear (improve the message/scripture). Add a fixture from the flagged code above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions