Skip to content

[prophet-report] SuggestCompareSelfTraitProphet: False positive on a non-enum. WireType is a 'final readonly class' with strin… #4

@jessegall

Description

@jessegall

Reported automatically by a code-commandments agent.

Prophet SuggestCompareSelfTraitProphet
Location src/Pipeline/Execution/WireType.php:80

What's wrong

False positive on a non-enum. WireType is a 'final readonly class' with string CONSTANTS (MIXED, STRING, INT, ...), not a backed enum. The CompareSelf trait is enum-only (it wraps enum-case === via an equals() API). Suggesting WireType '[ADOPT] CompareSelf' is invalid — a class can't be a CompareSelf enum, and $token === self::MIXED is a plain string-constant comparison, not enum-case equality. The prophet should only flag actual enums (is_enum), not classes that happen to compare $x === self::CONST.

Flagged code

if ($token === null || $token === self::MIXED)

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