Releases: bigbite/phpcs-config
v3.0.0
What's Changed
- Update authors in composer.json by @jaymcp in #159
- Introduce more comprehensive docblock coverage by @jaymcp in #168
- Add support for Enums to filename sniff by @jaymcp in #170
- Add new Sniff to restrict line length in docblocks by @jaymcp in #171
- Implement new rules for further conformity checking by @jaymcp in #169
- Add Sniff to ensure usage of Stringable interface by @jaymcp in #172
- Implement Sniff to ensure a blank line before an object's closing brace by @jaymcp in #173
- Implement Sniff to ensure a blank line after an object's opening brace by @jaymcp in #174
- Add sniff to ban heredocs. by @jaymcp in #175
- Add Sniff to enforce shorthand array syntax by @jaymcp in #177
- Run tests against PHP 8.4 in CI by @jaymcp in #178
- Add new Sniff to check declare statements by @jaymcp in #179
- Update line length sniff to disregard long parameter type hints by @jaymcp in #180
- Update line length sniff to disregard lines containing specific prefixes by @jaymcp in #181
- Add several new Sniffs from the Universal standard by @jaymcp in #182
- Move all documentation Sniffs to a separate standard by @jaymcp in #183
- Bump minimum PHP version to 8.2; set PHPStan to level 8 by @jaymcp in #184
- Exclude increment/decrement Sniff that conflicts with our standard by @jaymcp in #186
- Remove tag restrictions from class comments by @jaymcp in #187
- Move DocCommentLineLength Sniff to Docs ruleset by @jaymcp in #188
- Fix stringable sniff to account for namespaces by @jaymcp in #189
- Enable PHPCS scanning of test directories by @jaymcp in #191
- Replace
Squiz.Commenting.FunctionCommentwith new Sniff by @jaymcp in #192
Full Changelog: v2.0.1...v3.0.0
Upgrading
The ruleset PHP minimum version has been bumped to 7.2, and should work without issue on that version and above.
The ruleset will default to analysing against PHP 8.2 and above by default.
To change your project's PHP version requirement, set this config in your PHPCS config file:
<config name="testVersion" value="8.0-" />The terminal output now has colours! 🎉
File exclusion changes
The list of excluded file patterns has been updated:
- Tests directories are no longer exempt
- Built asset files from Build Tools are now exempt (
*/dist/*.asset.php) - Built asset files from WP Scripts are now exempt (
*/build/*.asset.php)
For projects that implement PHP tests, you are likely to encounter lots of new errors from files that have not previously been analysed.
Rule changes
There are many individual rule changes, so they have been broken up into code and documentation sections.
"Documentation", in this case, refers to code documentation - comments, docblocks, etc.., and will still only analyse PHP files.
Code
Several changes have been made to our custom sniffs, and a few new custom sniffs have been added:
- The presence of a heredoc will now trigger an error
Sniff:BigBite.PHP.Heredoc
Use string interpolation or sprintf instead. - A blank line between an object declaration and the first content within is now enforced
Sniff:BigBite.Objects.NewLineAfterOpeningBrace
This sniff includes a fixer. - A blank line between the last content within an object declaration and the object's closing brace is now enforced
Sniff:BigBite.Objects.NewLineBeforeClosingBrace
This sniff includes a fixer. - When using PHP 8.0 or higher, classes that implement the
__toStringmethod must now implement theStringableinterface
Sniff:BigBite.Classes.Stringable
This sniff includes a fixer. - The format of declare statements, where present, is now enforced
Sniff:BigBite.Files.DeclareStatement
This sniff includes a fixer, and enforces the following format:- the declare keyword should be lower case
- no space between the keyword and opening parenthesis
- one space after the opening parenthesis
- one space before the equals sign
- one space after the equals sign
- one space before the closing parenthesis
- no space between the closing parenthesis and terminating semi-colon
- one space between the closing parenthesis and opening curly brace in a block declaration
- the opening curly brace should be the last content on the line
- the closing curly brace in a block declaration should be on a new line
- the closing curly brace should be column-aligned with the declare keyword
- the only supported directives are
ticks,strict_types, orencoding
- The
BigBite.Files.FileNamesniff has been updated to include enums.
Enums should follow the same convention as classes, interfaces, and traits (enum-my-enum.php).
In addition to custom rules, we now also include rules from other standards:
-
both pre-increment/decrement (
++$i/--$i) and post-increment/decrement ($i++/$i--) are disallowed
Sniff:SlevomatCodingStandard.Operators.DisallowIncrementAndDecrementOperators
This has always been our standard, but now it is correctly enforced. -
modern usage of
dirnameis enforced__DIR__should be used instead ofdirname( __FILE__ )- a count should be passed as the second argument of
dirname, rather than nested calls
Sniff:
Modernize.FunctionCalls.Dirname -
mixing unkeyed and keyed array items is disallowed
Sniff:Universal.Arrays.MixedKeyedUnkeyedArray
Note: this rule will sometimes need to be ignored for taxonomy queries in WP -
interface implementation and class extension lists should be alphabetically sorted
Sniff:Universal.OOStructures.AlphabeticExtendsImplements -
usestatements should be alphabetised
Sniff:SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses -
usage of grouping in
usestatements (via{}) is disallowed
Sniff:SlevomatCodingStandard.Namespaces.DisallowGroupUse -
unused
usestatements will throw an error
Sniff:SlevomatCodingStandard.Namespaces.UnusedUses -
loose equality is disallowed
Sniff:SlevomatCodingStandard.Operators.DisallowEqualOperators -
variable variables are disallowed (
$$var)
Sniff:SlevomatCodingStandard.Variables.DisallowVariableVariable -
unused variables will throw an error
Sniff:SlevomatCodingStandard.Variables.UnusedVariable -
useless variables will throw an error
Sniff:SlevomatCodingStandard.Variables.UselessVariable
Documentation
We now no longer include the WordPress-Docs standard from WPCS.
The BigBite ruleset no longer contains any documentation-specific sniffs.
Instead, a new ruleset has been created to encompass these sniffs (BigBiteDocs).
The BigBite ruleset imports BigBiteDocs, so no user action is required to maintain documentation sniffing.
The documentation ruleset itself is now much more comprehensive, and it is here where you are most likely to encounter the most error codes when upgrading.
It is primarily for this reason that we're releasing this as a breaking change, and it's recommended to only think about backporting it to existing projects when one has plenty of time to address the issues it will report.
The most major change is the removal of Squiz.Commenting.FunctionComment in favour of our own custom version (BigBite.Commenting.FunctionComment).
The reason for this is that, although Squiz's version covers most of our function comment standards, there are some areas in which we differ.
Additionally, the Squiz sniff is missing fixers, so all non-conforming comments would need manual effort to resolve.
When upgrading existing projects, this is prohibitively time consuming.
So, we extended the Squiz sniff, modified some of its standards, and added fixers for as many violations as possible.
We've also introduced a sniff to limit the line length of doc comments (BigBite.Commenting.DocCommentLineLength).
This sniff is configurable but, by default:
- lines longer than 80 characters, but shorter than 100, will trigger a warning
- lines longer than 100 characters will trigger an error
- leading indentation does not contribute to the line length
- parameter type hints do not contribute to the line length
- lines starting with
Description:will be ignored (to allow plugin/theme comments) - lines that contain no whitespace (to allow things like URLs)
To configure this sniff:
<rule ref="BigBite.Commenting.DocCommentLineLength">
<property name="lineLimit" value="100" />
<property name="absoluteLineLimit" value="150" />
<property name="includeIndentation" value="true" />
<property name="descriptorsToIgnore" type="array">
<e...v3.0.0-beta.5
v3.0.0-beta.4
What's Changed
Full Changelog: v3.0.0-beta.3...v3.0.0-beta.4
v3.0.0-beta.3
What's Changed
- Exclude increment/decrement Sniff that conflicts with our standard by @jaymcp in #186
- Remove tag restrictions from class comments by @jaymcp in #187
Full Changelog: v3.0.0-beta.2...v3.0.0-beta.3
v3.0.0-beta.2
What's Changed
- Update line length sniff to disregard long parameter type hints by @jaymcp in #180
- Update line length sniff to disregard lines containing specific prefixes by @jaymcp in #181
- Add several new Sniffs from the Universal standard by @jaymcp in #182
- Move all documentation Sniffs to a separate standard by @jaymcp in #183
- Bump minimum PHP version to 8.2; set PHPStan to level 8 by @jaymcp in #184
Full Changelog: v3.0.0-beta.1...v3.0.0-beta.2
v3.0.0-beta.1
What's Changed
- Update authors in composer.json by @jaymcp in #159
- Introduce more comprehensive docblock coverage by @jaymcp in #168
- Add support for Enums to filename sniff by @jaymcp in #170
- Add new Sniff to restrict line length in docblocks by @jaymcp in #171
- Implement new rules for further conformity checking by @jaymcp in #169
- Add Sniff to ensure usage of Stringable interface by @jaymcp in #172
- Implement Sniff to ensure a blank line before an object's closing brace by @jaymcp in #173
- Implement Sniff to ensure a blank line after an object's opening brace by @jaymcp in #174
- Add sniff to ban heredocs. by @jaymcp in #175
- Add Sniff to enforce shorthand array syntax by @jaymcp in #177
- Run tests against PHP 8.4 in CI by @jaymcp in #178
- Add new Sniff to check declare statements by @jaymcp in #179
Full Changelog: v2.0.1...v3.0.0
v2.0.1
What's Changed
- chore(deps-dev): bump phpstan/phpstan from 1.10.41 to 1.10.48 by @dependabot in #135
- chore(deps): bump phpcsstandards/phpcsextra from 1.1.2 to 1.2.1 by @dependabot in #136
- chore(deps): bump phpcsstandards/phpcsutils from 1.0.8 to 1.0.9 by @dependabot in #137
- chore(deps): bump squizlabs/php_codesniffer from 3.7.2 to 3.8.0 by @dependabot in #138
- chore(deps-dev): bump phpstan/phpstan from 1.10.48 to 1.10.55 by @dependabot in #140
- chore(deps-dev): bump phpstan/phpstan from 1.10.55 to 1.10.58 by @dependabot in #145
- Remove PEAR.Commenting.InlineComment sniff by @jaymcp in #144
- Remove duplicate rules by @jaymcp in #146
- chore(deps): bump squizlabs/php_codesniffer from 3.8.0 to 3.8.1 by @dependabot in #141
- Bump PHPCS and PHPUnit versions by @jaymcp in #147
Full Changelog: v2.0.0...v2.0.1
v2.0.0
This release requires WPCS 3.0.0 and VIP WPCS 3.0.0, and contains breaking changes.
Changelog
- Modify the ruleset's PHPCS ruleset to use the ruleset included in WPCS v3.0.0
- Upgrade and reorganise dependencies to reflect changes introduced in WPCS v3.0.0
- Upgrade BigBite.Files.FileName sniff to reflect changes introduced in WPCS v3.0.0
- Skip output of BigBite.Files.FileName.NotHyphenatedLowercase error if covered by other error codes (fixes #96)
- Introduce several new sniffs - see "Sniff changes" below
- Fixes #119
Sniff changes
For the full list of upstream changes, see the WPCS release notes and VIP WPCS release notes
We have also introduced several new sniffs that have been made available as a result of the incredible work of the WPCS team:
Universal.FunctionDeclarations.NoLongClosures
Detects "long" closures and recommends using a named function instead.
Configured to warn at 5 lines and error at 8 lines.
This has potential to cause new errors in your projects if you heavily utilise closures.
This is a good thing, because long closures have always been discouraged by our style guide in a WordPress context.
Universal.FunctionDeclarations.RequireFinalMethodsInTraits
Enforces qualified methods (i.e. not abstract) in traits to be declared as final when such methods are not declared as private.
Universal.Operators.DisallowLogicalAndOr
Enforces the use of boolean operators (&&, ||) instead of logical operators (and, or).
Known breaking changes
Universal.NamingConventions.NoReservedKeywordParameterNames
A new upstream sniff which disallows use of "reserved" keywords as function parameter names ($list, $class`, etc.).
Universal.FunctionDeclarations.NoLongClosures
A new sniff which disallows the use of "long" closures, in favour of named functions.
Universal.UseStatements.NoUselessAliases
Disallows renaming of imports where there is no collision (use Foo\Bar\Baz as Qux).
v2.0.0-beta.2
What's Changed
- chore(deps): bump phpcsstandards/phpcsextra from 1.1.1 to 1.1.2 by @dependabot in #124
- chore(deps): bump wp-coding-standards/wpcs from 3.0.0 to 3.0.1 by @dependabot in #125
- chore(deps): bump dealerdirect/phpcodesniffer-composer-installer from 0.7.2 to 1.0.0 by @dependabot in #126
- chore(deps-dev): bump phpstan/phpstan from 1.10.38 to 1.10.40 by @dependabot in #128
- chore(deps-dev): bump phpstan/phpstan from 1.10.40 to 1.10.41 by @dependabot in #130
Full Changelog: v2.0.0-beta.1...v2.0.0-beta.2
v2.0.0-beta.1
What's Changed
- Remove Travis and move routines to CircleCI by @ampersarnie in #68
- Bump phpstan/phpstan from 1.9.2 to 1.9.3 by @dependabot in #69
- Bump phpstan/phpstan from 1.9.3 to 1.9.4 by @dependabot in #70
- Bump phpstan/phpstan from 1.9.4 to 1.9.7 by @dependabot in #73
- Bump phpcsstandards/phpcsdevtools from 1.2.0 to 1.2.1 by @dependabot in #74
- Bump phpstan/phpstan from 1.9.7 to 1.9.8 by @dependabot in #75
- Bump phpstan/phpstan from 1.9.8 to 1.9.9 by @dependabot in #76
- Bump phpstan/phpstan from 1.9.9 to 1.9.11 by @dependabot in #77
- Bump phpstan/phpstan from 1.9.11 to 1.9.12 by @dependabot in #78
- Bump phpstan/phpstan from 1.9.12 to 1.9.13 by @dependabot in #79
- Bump phpstan/phpstan from 1.9.13 to 1.9.14 by @dependabot in #80
- Bump phpstan/phpstan from 1.9.14 to 1.9.17 by @dependabot in #82
- Bump phpstan/phpstan from 1.9.17 to 1.9.18 by @dependabot in #83
- Bump phpstan/phpstan from 1.9.18 to 1.10.1 by @dependabot in #84
- Bump squizlabs/php_codesniffer from 3.7.1 to 3.7.2 by @dependabot in #85
- Bump phpstan/phpstan from 1.10.1 to 1.10.2 by @dependabot in #86
- Bump phpstan/phpstan from 1.10.2 to 1.10.3 by @dependabot in #87
- Bump phpstan/phpstan from 1.10.3 to 1.10.4 by @dependabot in #88
- Bump phpstan/phpstan from 1.10.4 to 1.10.5 by @dependabot in #89
- Bump phpstan/phpstan from 1.10.5 to 1.10.6 by @dependabot in #90
- Bump phpstan/phpstan from 1.10.6 to 1.10.7 by @dependabot in #91
- Bump phpstan/phpstan from 1.10.7 to 1.10.8 by @dependabot in #92
- Bump phpstan/phpstan from 1.10.8 to 1.10.9 by @dependabot in #93
- Bump phpstan/phpstan from 1.10.9 to 1.10.10 by @dependabot in #94
- Bump phpstan/phpstan from 1.10.10 to 1.10.11 by @dependabot in #95
- Bump phpstan/phpstan from 1.10.11 to 1.10.13 by @dependabot in #97
- chore(deps-dev): bump phpstan/phpstan from 1.10.13 to 1.10.14 by @dependabot in #98
- chore(deps-dev): bump phpstan/phpstan from 1.10.14 to 1.10.15 by @dependabot in #99
- chore(deps-dev): bump phpstan/phpstan from 1.10.15 to 1.10.16 by @dependabot in #100
- chore(deps-dev): bump phpstan/phpstan from 1.10.16 to 1.10.18 by @dependabot in #101
- chore(deps-dev): bump phpstan/phpstan from 1.10.18 to 1.10.19 by @dependabot in #102
- chore(deps-dev): bump phpstan/phpstan from 1.10.19 to 1.10.20 by @dependabot in #103
- chore(deps-dev): bump phpstan/phpstan from 1.10.20 to 1.10.21 by @dependabot in #104
- chore(deps-dev): bump phpstan/phpstan from 1.10.21 to 1.10.22 by @dependabot in #105
- chore(deps-dev): bump phpstan/phpstan from 1.10.22 to 1.10.23 by @dependabot in #106
- chore(deps-dev): bump phpstan/phpstan from 1.10.23 to 1.10.24 by @dependabot in #107
- chore(deps-dev): bump phpstan/phpstan from 1.10.24 to 1.10.25 by @dependabot in #108
- chore(deps-dev): bump phpstan/phpstan from 1.10.25 to 1.10.26 by @dependabot in #109
- chore(deps-dev): bump phpstan/phpstan from 1.10.26 to 1.10.27 by @dependabot in #110
- chore(deps-dev): bump phpstan/phpstan from 1.10.27 to 1.10.28 by @dependabot in #111
- chore(deps-dev): bump phpstan/phpstan from 1.10.28 to 1.10.29 by @dependabot in #112
- chore(deps-dev): bump phpstan/phpstan from 1.10.29 to 1.10.30 by @dependabot in #113
- chore(deps-dev): bump phpstan/phpstan from 1.10.30 to 1.10.32 by @dependabot in #114
- v2.0.0 by @jaymcp in #116
- chore(deps-dev): bump phpstan/phpstan from 1.10.32 to 1.10.38 by @dependabot in #123
Full Changelog: v1.2.0...v2.0.0-beta.1