Skip to content

Commit

Permalink
CS: Work around WPCS trim() bug
Browse files Browse the repository at this point in the history
PHP 8.1 increased the strictness of types used with native functions, and this meant WPCS 2.3.0 had a bug: WordPress/WordPress-Coding-Standards#2035

For the VIPCS coding standards check with PHP 8.1 or above it would report incorrect violations from sniffs that included the retrieval of optional command-line arguments. These violations did not appear when running PHPCS with PHP 8.0 or below.

Since the retrieval of the optional command-line arguments appeared to be coming through as null, causing the problems, the command to run PHPCS on the VIPCS codebase now includes setting of several command-line arguments.

With the `prefixes` enabled, extra sniff behaviour is enabled, and VIPCS has no need to adhere to consistent prefixes (unlike actual WordPress plugin and theme codebases). As such, the PrefixAllGlobals rule is excluded for VIPCS.

When WPCS 3.0 is the minimum supported, these changes can be reverted.
  • Loading branch information
GaryJones committed Jan 30, 2023
1 parent 1d052c9 commit aa35f43
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<rule ref="WordPress-Extra">
<exclude name="WordPress.Files.FileName"/>
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
<exclude name="WordPress.NamingConventions.PrefixAllGlobals"/>
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="WordPress.PHP.YodaConditions"/>
</rule>
Expand Down
2 changes: 1 addition & 1 deletion bin/phpcs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
#
# ./bin/phpcs

"$(pwd)/vendor/bin/phpcs"
"$(pwd)/vendor/bin/phpcs" --runtime-set minimum_supported_wp_version 0 --runtime-set prefixes foo --runtime-set text_domain foo

0 comments on commit aa35f43

Please sign in to comment.