PHP_CodeSniffer
PHP_CodeSniffer copied to clipboard
PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
# Description ### Common::getSniffCode(): add tests Add initial set of tests for the `Common::getSniffCode()` method. Related to #146 Related to [review comment in PR 446](https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/446#discussion_r1573947430). ### Common::getSniffCode(): throw exception on...
## Describe the bug Destructuring an array for foreach - `foreach ($data as [, , $value]) {` - violates the `Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma` ("Expected 0 spaces between "," and comma; 1 found")...
## Describe the bug Array destructuring is a syntax in PHP where items of an array are assigned to single variables, using an array construct on the left of the...
## Motivation Sniffs should always be able to rely on the token arrays declared as static properties in the `Tokens` to be stable. These token arrays should never be changed/updated...
Inspired by the conversation in [this PR review thread](https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/446#discussion_r1564596545). PHPCS uses `for`/`foreach`/`while` loops _a lot_ and quite often the variables created for those loops are not destroyed after the loop...
## Is your feature request related to a problem? When writing some sniff fixes, it's necessary to remove an entire line. Currently there is no helper for this. This is...
**Describe the bug** This bug was originally reported here: https://github.com/squizlabs/PHP_CodeSniffer/issues/3564 Forgive me if there is already a ticket for this or if it should not reported again here. But I...
# Description Follow up to squizlabs/PHP_CodeSniffer#3716 and PR #524. PR squizlabs/PHP_CodeSniffer#3716 improved the information provided in the error messages for `Internal.Exception`s with additional information about the source of the problem....
The spacing after the `final` keyword should be checked by ScopeKeywordSpacingSniff. # Description This should throw an error because there are 6 spaces after `final`: ```php class FinalTest { final...
# Description As originally discussed in https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/482#pullrequestreview-2062765716 (see the "Commit 2 - stop listening for T_SWITCH" section), this PR changes the `Generic.ControlStructures.InlineControlStructure` sniff to stop listening for `T_SWITCH` tokens as...