Skip to content

[prophet-report] SuggestCompareSelfTraitProphet: Prophet/PHPStan conflict: the rule now MANDATES the case-anchored instance fo… #6

@jessegall

Description

@jessegall

Reported automatically by a code-commandments agent.

Prophet SuggestCompareSelfTraitProphet
Location src/Support/Enums/CompareSelf.php

What's wrong

Prophet/PHPStan conflict: the rule now MANDATES the case-anchored instance form Enum::Case->equals($x) (static Enum::equals($x, Case) against a literal case is a sin). But that instance call does NOT type-check at PHPStan max level: PHPStan resolves NodeType::Control->equals($x) against the trait's STATIC @method static bool equals(mixed $value, self $case) (2 required) rather than the instance @method bool equals(mixed $value), producing 'Method NodeType::equals() invoked with 1 parameter, 2 required' (arguments.count) + argument.type errors on EVERY case-anchored call repo-wide (~69). The two same-named @method declarations (instance + static) on CompareSelf are ambiguous to PHPStan when the receiver is an enum case. Either the generated CompareSelf trait needs PHPStan-resolvable annotations (or real methods) for the dual instance/static API, or the prophet should not mandate a form that fails the type checker.

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