Skip to content

[prophet-report] NoRawLiteralProphet: False positive with a BEHAVIOR-CHANGING suggested fix. Flags `(string) ($x ??… #3

@jessegall

Description

@jessegall

Reported automatically by a code-commandments agent.

Prophet NoRawLiteralProphet
Location src/Workflow/Nodes/Utilities/SplitNode/SplitNode.php:126

What's wrong

False positive with a BEHAVIOR-CHANGING suggested fix. Flags (string) ($x ?? T_String::COMMA) claiming it coalesces 'to a T_String empty' and suggests T_String::coalesce($x ?? null). But T_String::COMMA is ',' (NOT empty), and T_String::coalesce($x ?? null) returns $x ?? '' — i.e. it would silently change the default from ',' to ''. The rule must only fire when the coalesce fallback is genuinely the T_String EMPTY constant; a non-empty constant fallback (COMMA, SPACE, etc.) is not the same idiom and its autofix corrupts behavior.

Flagged code

$delimiter = (string) ($this->received->get('delimiter') ?? T_String::COMMA);

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