Skip to content

Commit 6ee142e

Browse files
authored
Merge pull request #2539 from WordPress/feature/ghactions-add-spellcheck
GH Actions: add a basic spellcheck CI check + fix some typos
2 parents b3713e7 + 99dc5ee commit 6ee142e

20 files changed

+78
-40
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Alternatively, if you have push access to this repo, create a feature branch pre
3131
## Public properties
3232

3333
When writing sniffs, always remember that any `public` sniff property can be overruled via a custom ruleset by the end-user.
34-
Only make a property `public` if that is the intended behaviour.
34+
Only make a property `public` if that is the intended behavior.
3535

3636
When you introduce new `public` sniff properties, or your sniff extends a class from which you inherit a `public` property, please don't forget to update the [public properties wiki page](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) with the relevant details once your PR has been merged into the `develop` branch.
3737

.github/workflows/basic-qa.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,15 @@ jobs:
254254

255255
- name: Run PHPStan
256256
run: phpstan analyse
257+
258+
typos-check:
259+
name: "Find typos"
260+
261+
runs-on: "ubuntu-latest"
262+
263+
steps:
264+
- name: "Checkout"
265+
uses: "actions/checkout@v4"
266+
267+
- name: "Search for misspellings"
268+
uses: "crate-ci/typos@v1"

CHANGELOG.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ If you are a maintainer of an external standard based on WordPressCS and any of
768768
- The `vip_powered_wpcom` function from the `Sniff::$autoEscapedFunctions` list which is used by the `WordPress.Security.EscapeOutput` sniff.
769769
- The `AbstractVariableRestrictionsSniff` class, which was deprecated since WordPressCS 1.0.0.
770770
- The `Sniff::has_html_open_tag()` utility method, which was deprecated since WordPressCS 1.0.0.
771-
- The internal `$php_reserved_vars` property from the `WordPress.NamingConventions.ValidVariableName` sniff in favour of using a PHPCS native property which is now available.
771+
- The internal `$php_reserved_vars` property from the `WordPress.NamingConventions.ValidVariableName` sniff in favor of using a PHPCS native property which is now available.
772772
- The class aliases and WPCS native autoloader used for PHPCS cross-version support.
773773
- The unit test framework workarounds for PHPCS cross-version unit testing.
774774
- Support for the `@codingStandardsChangeSetting` annotation, which is generally only used in unit tests.
@@ -865,8 +865,8 @@ Note: This will be the last release supporting PHP_CodeSniffer 2.x.
865865

866866
### Changed
867867
- The `PEAR.Functions.FunctionCallSignature` sniff, which is part of the `WordPress-Core` ruleset, used to allow multiple function call parameters per line in multi-line function calls. This will no longer be allowed.
868-
As of this release, if a function call is multi-line, each parameter should start on a new line and an `error` will be thrown if the code being analysed does not comply with that rule.
869-
The sniff behaviour for single-line function calls is not affected by this change.
868+
As of this release, if a function call is multi-line, each parameter should start on a new line and an `error` will be thrown if the code being analyzed does not comply with that rule.
869+
The sniff behavior for single-line function calls is not affected by this change.
870870
- Moved the `WordPress.CodeAnalysis.EmptyStatement` sniff from the `WordPress-Extra` to the `WordPress-Core` ruleset.
871871
- Moved the `Squiz.PHP.CommentedOutCode` sniff from the `WordPress-Docs` to the `WordPress-Extra` ruleset and lowered the threshold for determining whether or not a comment is commented out code from 45% to 40%.
872872
- The `WordPress.NamingConventions.PrefixAllGlobals` sniff now has improved support for recognizing whether or not (non-prefixed) globals are declared in the context of unit tests.
@@ -881,7 +881,7 @@ Note: This will be the last release supporting PHP_CodeSniffer 2.x.
881881
### Fixed
882882
- The `WordPress.Security.ValidatedSanitizedInput` sniff will now recognize array keys in superglobals independently of the string quote-style used for the array key.
883883
- The `WordPress.WhiteSpace.PrecisionAlignment` sniff will no longer throw false positives for DocBlocks for JavaScript functions within inline HTML.
884-
- `WordPress.WP.DeprecatedClasses`: The error codes for this sniff were unstable as they were based on the code being analysed instead of on fixed values.
884+
- `WordPress.WP.DeprecatedClasses`: The error codes for this sniff were unstable as they were based on the code being analyzed instead of on fixed values.
885885
- Various bugfixes for the `WordPress.WP.GlobalVariablesOverride` sniff:
886886
- Previously, the sniff only checked variables in the global namespace when a `global` statement would be encountered. As of now, all variable assignments in the global namespace will be checked.
887887
- Nested functions/closures/classes which don't import the global variable will now be skipped over when encountered within another function, preventing false positives.
@@ -1089,8 +1089,8 @@ If you are a maintainer of an external standard based on WPCS and any of your cu
10891089

10901090
### Added
10911091
- `WordPress.Arrays.MultipleStatementAlignment` sniff to the `WordPress-Core` ruleset which will align the array assignment operator for multi-item, multi-line associative arrays.
1092-
This new sniff offers four custom properties to customize its behaviour: [`ignoreNewlines`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-allow-for-new-lines), [`exact`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-allow-non-exact-alignment), [`maxColumn`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-maximum-column) and [`alignMultilineItems`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-dealing-with-multi-line-items).
1093-
- `WordPress.DB.PreparedSQLPlaceholders` sniff to the `WordPress-Core` ruleset which will analyse the placeholders passed to `$wpdb->prepare()` for their validity, check whether queries using `IN ()` and `LIKE` statements are created correctly and will check whether a correct number of replacements are passed.
1092+
This new sniff offers four custom properties to customize its behavior: [`ignoreNewlines`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-allow-for-new-lines), [`exact`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-allow-non-exact-alignment), [`maxColumn`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-maximum-column) and [`alignMultilineItems`](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#array-alignment-dealing-with-multi-line-items).
1093+
- `WordPress.DB.PreparedSQLPlaceholders` sniff to the `WordPress-Core` ruleset which will analyze the placeholders passed to `$wpdb->prepare()` for their validity, check whether queries using `IN ()` and `LIKE` statements are created correctly and will check whether a correct number of replacements are passed.
10941094
This sniff should help detect queries which are impacted by the security fixes to `$wpdb->prepare()` which shipped with WP 4.8.2 and 4.8.3.
10951095
The sniff also adds a new ["PreparedSQLPlaceholders replacement count" whitelist comment](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors#preparedsql-placeholders-vs-replacements) for pertinent replacement count vs placeholder mismatches. Please consider carefully whether something could be a bug when you are tempted to use the whitelist comment and if so, [report it](https://github.com/WordPress/WordPress-Coding-Standards/issues/new).
10961096
- `WordPress.PHP.DiscourageGoto` sniff to the `WordPress-Core` ruleset.
@@ -1110,7 +1110,7 @@ If you are a maintainer of an external standard based on WPCS and any of your cu
11101110
- When passing an array property via a custom ruleset to PHP_CodeSniffer, spaces around the key/value are taken as intentional and parsed as part of the array key/value. In practice, this leads to confusion and WPCS does not expect any values which could be preceded/followed by a space, so for the WordPress Coding Standard native array properties, like `customAutoEscapedFunction`, `text_domain`, `prefixes`, WPCS will now trim whitespace from the keys/values received before use.
11111111
- The WPCS native whitelist comments used to only work when they were put on the _end of the line_ of the code they applied to. As of now, they will also be recognized when they are be put at the _end of the statement_ they apply to.
11121112
- The `WordPress.Arrays.ArrayDeclarationSpacing` sniff used to enforce all associative arrays to be multi-line. The handbook has been updated to only require this for multi-item associative arrays and the sniff has been updated accordingly.
1113-
[The original behaviour can still be enforced](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#arrays-forcing-single-item-associative-arrays-to-be-multi-line) by setting the new `allow_single_item_single_line_associative_arrays` property to `false` in a custom ruleset.
1113+
[The original behavior can still be enforced](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#arrays-forcing-single-item-associative-arrays-to-be-multi-line) by setting the new `allow_single_item_single_line_associative_arrays` property to `false` in a custom ruleset.
11141114
- The `WordPress.NamingConventions.PrefixAllGlobals` sniff will now allow for a limited list of WP core hooks which are intended to be called by plugins and themes.
11151115
- The `WordPress.PHP.DiscouragedFunctions` sniff used to include `create_function`. This check has been moved to the new `WordPress.PHP.RestrictedFunctions` sniff.
11161116
- The `WordPress.PHP.StrictInArray` sniff now has a separate error code `FoundNonStrictFalse` for when the `$strict` parameter has been set to `false`. This allows for excluding the warnings for that particular situation, which will normally be intentional, via a custom ruleset.
@@ -1329,7 +1329,7 @@ You are also encouraged to check the file history of any WPCS classes you extend
13291329
### Removed
13301330
- Warnings thrown by individual sniffs about parse errors they encounter. This is left up to the `Generic.PHP.Syntax` sniff which is included in the `WordPress-Extra` ruleset.
13311331
- The `post_class()` function from the `autoEscapedFunctions` list used by the `WordPress.XSS.EscapeOutput` sniff.
1332-
- The `Generic.Files.LowercasedFilename` sniff from the `WordPress-Core` ruleset in favour of the improved `WordPress.Files.FileName` sniff to prevent duplicate messages being thrown.
1332+
- The `Generic.Files.LowercasedFilename` sniff from the `WordPress-Core` ruleset in favor of the improved `WordPress.Files.FileName` sniff to prevent duplicate messages being thrown.
13331333
- Some temporary work-arounds for changes which were pulled and merged into PHPCS upstream.
13341334

13351335
### Fixed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* [Rulesets](#rulesets)
3131
+ [Standards subsets](#standards-subsets)
3232
+ [Using a custom ruleset](#using-a-custom-ruleset)
33-
+ [Customizing sniff behaviour](#customizing-sniff-behaviour)
33+
+ [Customizing sniff behavior](#customizing-sniff-behavior)
3434
+ [Recommended additional rulesets](#recommended-additional-rulesets)
3535
* [How to use](#how-to-use)
3636
+ [Command line](#command-line)
@@ -135,9 +135,9 @@ When you name this file either `.phpcs.xml`, `phpcs.xml`, `.phpcs.xml.dist` or `
135135

136136
For more info, read about [using a default configuration file](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file). See also the provided WordPressCS [`phpcs.xml.dist.sample`](phpcs.xml.dist.sample) file and the [fully annotated example ruleset](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-ruleset.xml) in the PHP_CodeSniffer documentation.
137137

138-
### Customizing sniff behaviour
138+
### Customizing sniff behavior
139139

140-
The WordPress Coding Standard contains a number of sniffs which are configurable. This means that you can turn parts of the sniff on or off, or change the behaviour by setting a property for the sniff in your custom `[.]phpcs.xml[.dist]` file.
140+
The WordPress Coding Standard contains a number of sniffs which are configurable. This means that you can turn parts of the sniff on or off, or change the behavior by setting a property for the sniff in your custom `[.]phpcs.xml[.dist]` file.
141141

142142
You can find a complete list of all the properties you can change for the WordPressCS sniffs in the [wiki](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties).
143143

@@ -151,7 +151,7 @@ Information on custom properties which can be set for sniffs from PHP_CodeSniffe
151151
#### PHPCompatibility
152152

153153
The [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) ruleset and its subset [PHPCompatibilityWP](https://github.com/PHPCompatibility/PHPCompatibilityWP) come highly recommended.
154-
The [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) sniffs are designed to analyse your code for cross-version PHP compatibility.
154+
The [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) sniffs are designed to analyze your code for cross-version PHP compatibility.
155155

156156
The [PHPCompatibilityWP](https://github.com/PHPCompatibility/PHPCompatibilityWP) ruleset is based on PHPCompatibility, but specifically crafted to prevent false positives for projects which expect to run within the context of WordPress, i.e. core, plugins and themes.
157157

WordPress-Core/ruleset.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@
718718
Ref: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#increment-decrement-operators
719719
#############################################################################
720720
-->
721-
<!-- Covers rule: Pre-increment/decrement should be favoured over post-increment/decrement
721+
<!-- Covers rule: Pre-increment/decrement should be favored over post-increment/decrement
722722
for stand-alone statements. -->
723723
<rule ref="Universal.Operators.DisallowStandalonePostIncrementDecrement">
724724
<type>warning</type>
@@ -778,7 +778,7 @@
778778
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
779779

780780
<!-- Covers rule: Unless absolutely necessary, loose comparisons should not be used,
781-
as their behaviour can be misleading. -->
781+
as their behavior can be misleading. -->
782782
<rule phpcs-only="true" ref="Universal.Operators.StrictComparisons">
783783
<type>warning</type>
784784
</rule>
@@ -940,8 +940,8 @@
940940
<!-- Check that class name references use the correct case. -->
941941
<rule ref="WordPress.WP.ClassNameCase"/>
942942

943-
<!-- Check that __DIR__ is favoured over dirname(__FILE__)
944-
and that dirname( __DIR__, $levels ) is favoured over nested calls to dirname().
943+
<!-- Check that __DIR__ is favored over dirname(__FILE__)
944+
and that dirname( __DIR__, $levels ) is favored over nested calls to dirname().
945945
See: https://core.trac.wordpress.org/ticket/48082 -->
946946
<rule ref="Modernize.FunctionCalls.Dirname"/>
947947

WordPress/AbstractArrayAssignmentRestrictionsSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Restricts array assignment of certain keys.
2222
*
2323
* @since 0.3.0
24-
* @since 0.10.0 Class became a proper abstract class. This was already the behaviour.
24+
* @since 0.10.0 Class became a proper abstract class. This was already the behavior.
2525
* Moved the file and renamed the class from
2626
* `\WordPressCS\WordPress\Sniffs\Arrays\ArrayAssignmentRestrictionsSniff` to
2727
* `\WordPressCS\WordPress\AbstractArrayAssignmentRestrictionsSniff`.

WordPress/AbstractFunctionRestrictionsSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Restricts usage of some functions.
2121
*
2222
* @since 0.3.0
23-
* @since 0.10.0 Class became a proper abstract class. This was already the behaviour.
23+
* @since 0.10.0 Class became a proper abstract class. This was already the behavior.
2424
* Moved the file and renamed the class from
2525
* `\WordPressCS\WordPress\Sniffs\Functions\FunctionRestrictionsSniff` to
2626
* `\WordPressCS\WordPress\AbstractFunctionRestrictionsSniff`.

WordPress/Docs/PHP/DontExtractStandard.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
>
66
<standard>
77
<![CDATA[
8-
Forbids the usage of the PHP native `extract()` function. Using `extract()` makes code harder to debug, harder to understand and may cause unexpected behaviour when variables names conflict.
8+
Forbids the usage of the PHP native `extract()` function. Using `extract()` makes code harder to debug, harder to understand and may cause unexpected behavior when variables names conflict.
99
]]>
1010
</standard>
1111
<code_comparison>

WordPress/Helpers/MinimumWPVersionTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ trait MinimumWPVersionTrait {
3535
* `WordPress.WP.DeprecatedClasses`, `WordPress.WP.DeprecatedFunctions`,
3636
* `WordPress.WP.DeprecatedParameter` and the `WordPress.WP.DeprecatedParameterValues` sniff.
3737
*
38-
* These sniffs will adapt their behaviour based on the minimum supported WP version
38+
* These sniffs will adapt their behavior based on the minimum supported WP version
3939
* indicated.
4040
* By default, it is set to presume that a project will support the current
4141
* WP version and up to three releases before.
@@ -141,7 +141,7 @@ final protected function wp_version_compare( $version1, $version2, $operator ) {
141141
* Ensures that a version number is comparable via the PHP version_compare() function
142142
* by making sure it complies with the minimum "PHP-standardized" version number requirements.
143143
*
144-
* Presumes the input is a numeric version number string. The behaviour with other input is undefined.
144+
* Presumes the input is a numeric version number string. The behavior with other input is undefined.
145145
*
146146
* @since 3.0.0
147147
*

WordPress/Helpers/WPDBTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ trait WPDBTrait {
3737
* @since 3.0.0 - Moved from the Sniff class to this dedicated Trait.
3838
* - The `$phpcsFile` parameter was added.
3939
*
40-
* {@internal This method should be refactored to not exhibit "magic" behaviour
40+
* {@internal This method should be refactored to not exhibit "magic" behavior
4141
* for properties in the sniff class(es) using it.}}
4242
*
4343
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.

0 commit comments

Comments
 (0)