Skip to content

Fix sniff error name in PHPCS error message #860

@mk-mxp

Description

@mk-mxp

In src/Sniffs/ExplainStrictTypesSniff.php we produce a addFixableError() with self::class. This shouldn't be the fully qualified class name, but an identifier unique for the error message like Missing.

This is not a functional problem, only an oddity in case of an error:

FILE: /home/runner/work/php/php/exercises/practice/meetup/.meta/example.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 2 | ERROR | [x] Missing explanation of declaration of strict types.
   |       |     (Exercism.StrictTypes.ExplainStrictTypes.Exercism\Sniffs\StrictTypes\ExplainStrictTypesSniff)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 4.12 secs; Memory: 8MB

The message identifier may be used to configure severity etc. The class name is converted to the dot notation correctly, and our custom message identifier is appended after the last dot. The FQCN here makes the message look broken and does not help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions