Skip to content

PSR2.Classes.ClassDeclaration: thorough review of the sniff code #425

Open
@jrfnl

Description

@jrfnl

As per the note left on PR #424 :

at a glance, this sniff could probably do with a more thorough review and more defensive token walking/more precise checking

And from a reply to a PR review:

For the record: the above note was triggered by seeing code like line 451-453 which checks that the code after a name is not a \ and not a comma and then presumes it is whitespace, but doesn't actually check if the token is whitespace (and replaces the token anyhow, potentially destroying valid code).

This will need further investigation (and proof of the bug via a code sample, not just my experience telling me there is a likely to be bug). It might be that the code earlier on in the sniff already checks for \, comma and whitespace, so that if the next token is not \ or comma, the sniff can be sure that it will be whitespace (but then again, why not check for that in line 451-453 ?).
Considering the bugs now fixed and seeing that code, I have a feeling there will be more, potentially incorrect, presumptions build into the sniff.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions