PHPCSStandards / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
937 stars 56 forks source link

Review use of `T_SEMICOLON` in sniffs #552

Open jrfnl opened 3 months ago

jrfnl commented 3 months ago

The bug as reported in #537 highlights an area where a full sniff review would not be amiss.

Basically any time a findPrevious()/findNext() call searches for a T_SEMICOLON token to find the end of a statement, or when using "manual" token walking, but again looking for a T_SEMICOLON, there is a chance that the sniff should also check for the T_CLOSE_TAG token (and/or possibly the T_OPEN_TAG/T_OPEN_TAG_WITH_ECHO tokens).

Keep in mind: the ?> in PHP will automatically inject a semi-colon if one is not already there.

Task list

A quick search of the code base yields the following files/sniffs which will need to be reviewed. I only expect a small number of these to need changes.

To Do

* Note: a few CSS/JS specific files have been excluded from the above task list as this is a PHP specific issue.

Under review

nothing yet

Reviewed and PR submitted with update

Reviewed and concluded no changes needed

Guidelines

Any changes made should be accompanied by one or more tests demonstrating the false positives/false negatives prevented by the change.

PRs for this ticket should preferably contain the changes for one sniff per PR.

If you want to contribute to this task, please leave a comment "claiming" one or more files you will be reviewing. This way we can prevent multiple people working on the same thing.

If a review concludes that no changes are needed, just note that in a comment as well and I'll update the above task list.