Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
0076d49
NamingConventions/ValidFunctionName: rename test case file
rodrigoprimo Jul 15, 2025
328d702
NamingConventions/ValidFunctionName: move test with intentional parse…
rodrigoprimo Jul 15, 2025
0620684
NamingConventions/ValidFunctionName: add tests using readonly anonymo…
rodrigoprimo Jul 15, 2025
d541631
NamingConventions/PrefixAllGlobals: modify a test to use readonly ano…
rodrigoprimo Jul 16, 2025
9e94d3b
NamingConventions/PrefixAllGlobals: add tests using asymmetric visibi…
rodrigoprimo Jul 17, 2025
fb50666
NamingConventions/ValidVariableName: add tests using asymmetric visib…
rodrigoprimo Jul 17, 2025
88d311f
Security/NonceVerification: add test using asymmetric visibility prop…
rodrigoprimo Jul 17, 2025
f5ebe18
WP/GlobalVariablesOverride: move parse error test to its own file
rodrigoprimo Jul 17, 2025
a1f0108
WP/GlobalVariablesOverride: add tests using asymmetric visibility pro…
rodrigoprimo Jul 17, 2025
a858fc9
PHP/YodaConditions: use new Collections::ternaryOperators() token array
jrfnl Jun 6, 2024
f09cf09
Files/FileName: start using the PHPCSUtils `FilePath` utility
jrfnl Jun 6, 2024
a74a579
Utils/I18nTextDomainFixer: start using the PHPCSUtils `FilePath` utility
jrfnl Jun 6, 2024
86b43ec
PHP 8.4 | Security/EscapeOutput: handle exit/die using named parameters
jrfnl Aug 23, 2024
59b7919
PHPCSUtils 1.1.0: only catch what should be caught
jrfnl Aug 23, 2024
793ff43
NamingConventions/ValidPostTypeSlug: check token via code, not type
jrfnl Jul 25, 2025
6b716a5
Merge pull request #2563 from WordPress/feature/use-phpcsutils-1.1.0
dingo-d Jul 29, 2025
c16646e
EscapingFunctionsTrait: remove `wp_kses_allowed_html()` from escaping…
jrfnl Jul 26, 2025
2bb6fc5
Merge pull request #2566 from WordPress/feature/escapingfunctions-rem…
jrfnl Aug 1, 2025
fa2b44e
Merge pull request #2562 from WordPress/feature/validposttypeslug-cle…
dingo-d Aug 1, 2025
afcb17e
Security/EscapeOutput: fix false negatives when handling anonymous cl…
rodrigoprimo Aug 2, 2025
4083546
GH Actions/unit-tests: don't run code coverage in forks
rodrigoprimo Aug 5, 2025
067740b
Merge pull request #2568 from rodrigoprimo/update-unit-test-workflow
dingo-d Aug 5, 2025
f2fbb58
DB/PreparedSQLPlaceholders: fix false negative when checking quotes i…
rodrigoprimo Aug 7, 2025
418cf1c
DB/PreparedSQL: fix false positives with case-insensitive function names
rodrigoprimo Aug 7, 2025
cc56685
Merge pull request #2569 from rodrigoprimo/prepared-sql-placeholders-…
dingo-d Aug 8, 2025
ede46ef
Merge pull request #2570 from rodrigoprimo/prepared-sql-fix-false-pos…
dingo-d Aug 8, 2025
afb6fb0
WP/EnqueuedResourceParameters: move parse error test to its own file
jrfnl Aug 13, 2025
7d376f8
PHP 8.5 | WP/EnqueuedResourceParameters: prevent deprecation notice f…
jrfnl Aug 13, 2025
94d1273
GH Actions: Bump actions/checkout from 4 to 5
dependabot[bot] Aug 18, 2025
298da73
Merge pull request #2576 from WordPress/dependabot/github_actions/act…
jrfnl Aug 18, 2025
009086d
GH Actions: update PHP ini configuration
jrfnl Aug 10, 2025
8daf2e7
DB/RestrictedClasses: remove redundant call to `parent::setUpPrerequi…
rodrigoprimo Aug 5, 2025
97ce822
Merge pull request #2573 from WordPress/feature/php-8.5-prevent-error…
dingo-d Aug 24, 2025
f8685a2
Merge pull request #2571 from jrfnl/feature/ghactions-show-startup-er…
dingo-d Aug 24, 2025
be6312a
Merge pull request #2551 from rodrigoprimo/asymmetric-visibility-prop…
dingo-d Aug 25, 2025
3dcb08a
Merge pull request #2550 from rodrigoprimo/readonly-anonymous-classes
dingo-d Aug 25, 2025
2403b00
Security/ValidatedSanitizedInput: fix link in docblock
rodrigoprimo Sep 2, 2025
fa635ad
Release checklist: minor updates to the publicize section (#2567)
rodrigoprimo Sep 3, 2025
e40de79
Merge pull request #2596 from rodrigoprimo/fix-validated-sanitized-in…
jrfnl Sep 3, 2025
8e7c15b
Changelog: add missing entry to the changelog
rodrigoprimo Sep 3, 2025
a0a289a
Merge pull request #2578 from rodrigoprimo/restricted-classes-remove-…
GaryJones Sep 3, 2025
be2c9af
Release checklist: add new bullet about checking all PRs are milestoned
jrfnl Sep 3, 2025
7200663
Changelog: add WPCS maintainers to the list of GitHub profile links
rodrigoprimo Sep 3, 2025
d74c169
Merge pull request #2599 from rodrigoprimo/update-changelog-missing-e…
jrfnl Sep 3, 2025
bdfc3fe
Merge pull request #2600 from WordPress/feature/release-checklist-min…
dingo-d Sep 3, 2025
6e6883b
Merge pull request #2601 from rodrigoprimo/changelog-fix-missing-cont…
jrfnl Sep 3, 2025
f6965ee
Update CONTRIBUTING.md with tips for successful PRs (#2598)
GaryJones Sep 4, 2025
0a020d1
Add PR template (#2594)
jrfnl Sep 8, 2025
8f85cbd
WP/AlternativeFunctions: fix typo in code comment
rodrigoprimo Sep 5, 2025
d3a45da
Merge pull request #2604 from rodrigoprimo/alternative-functions-fix-…
jrfnl Sep 9, 2025
bf362c6
Security/EscapeOutput: fix namespaced ::class detection
rodrigoprimo Aug 21, 2025
5b28561
Security/EscapeOutput: remove unintentional syntax error from the tests
rodrigoprimo Sep 10, 2025
fe9bacf
Example ruleset: update some recommended settings
jrfnl Sep 11, 2025
e113ed1
README: make the call for funding stand out a bit more
jrfnl Sep 11, 2025
6951677
CONTRIBUTING: update the example test output
jrfnl Sep 11, 2025
17875ff
Merge pull request #2605 from rodrigoprimo/escape-output-fix-namespac…
jrfnl Sep 15, 2025
af0edf3
Merge pull request #2609 from WordPress/feature/readme-update-funding
jrfnl Sep 15, 2025
cb9cf4d
Merge pull request #2610 from WordPress/feature/contributing-update-t…
jrfnl Sep 15, 2025
637711c
WP/GlobalVariablesOverride: more tests covering unresolvable `$GLOBAL…
rodrigoprimo Sep 15, 2025
584ef10
DB/DirectDatabaseQuery: rename test case file
rodrigoprimo Aug 7, 2025
b4cf66e
DB/DirectDatabaseQuery: move syntax error test to its own file
rodrigoprimo Aug 7, 2025
1bcf297
DB/DirectDatabaseQuery: make cache function name matching case-insens…
rodrigoprimo Aug 7, 2025
d03c848
Drop support for PHP < 7.2
jrfnl Sep 11, 2025
e43f301
Tests: use standardized fixture methods
rodrigoprimo Aug 5, 2025
781bb22
GH Actions: remove build with special set of extensions
jrfnl Sep 15, 2025
e26eb87
Merge pull request #2613 from rodrigoprimo/direct-database-query-case…
dingo-d Sep 16, 2025
5c819af
Merge pull request #2608 from WordPress/feature/example-ruleset-update
dingo-d Sep 16, 2025
7d15d40
Merge pull request #2614 from WordPress/feature/2606-drop-support-for…
jrfnl Sep 16, 2025
78b650d
DB/DirectDatabaseQuery: fix false negatives when cache function names…
rodrigoprimo Aug 7, 2025
9839cbd
Documentation: Update PHPCompatibilityWP version recommendation to 7.…
johnjago Sep 16, 2025
81d9dd4
PHP/POSIXFunctions: deprecate the sniff
jrfnl Sep 16, 2025
be1faba
CONTRIBUTING: update the test writing tutorial
jrfnl Sep 16, 2025
cb5e9e7
Merge pull request #2616 from WordPress/feature/2612-deprecate-posix-…
dingo-d Sep 17, 2025
2e98985
Merge pull request #2615 from rodrigoprimo/direct-database-query-fix-…
dingo-d Sep 17, 2025
93c8284
GH Actions: update for upstream branch rename (#2611)
jrfnl Sep 17, 2025
6f6485d
Security/NonceVerification: handle function names case correctly
rodrigoprimo Aug 12, 2025
fde3f7d
Ensure sniff handles custom nonce verification functions case correctly
rodrigoprimo Sep 3, 2025
89d3066
Add tests safeguarding that non-ANSCII characters are handled correct…
rodrigoprimo Sep 3, 2025
106aa59
Normalize `nonceVerificationFunctions` instead of `customNonceVerific…
rodrigoprimo Sep 4, 2025
2bc0492
AbstractFunctionRestrictions: add tests for namespaced names
rodrigoprimo Aug 21, 2025
225676a
DateTime/RestrictedFunctions: add tests for namespaced names
rodrigoprimo Aug 21, 2025
b95ef97
DB/RestrictedFunctions: add tests for namespaced names
rodrigoprimo Aug 21, 2025
248a2ac
PHP/DevelopmentFunctions: add tests for namespaced names
rodrigoprimo Aug 21, 2025
0671858
PHP/DiscouragedPHPFunctions: add tests for namespaced names
rodrigoprimo Aug 21, 2025
293e3e3
PHP/DontExtract: add tests for namespaced names
rodrigoprimo Aug 21, 2025
ea86386
PHP/POSIXFunctions: add tests for namespaced names
rodrigoprimo Aug 21, 2025
4197cea
PHP/RestrictedPHPFunctions: add tests for namespaced names
rodrigoprimo Aug 21, 2025
f8ed24b
Security/SafeRedirect: add tests for namespaced names
rodrigoprimo Aug 21, 2025
e44ef89
WP/DeprecatedFunctions: rename test case file
rodrigoprimo Aug 21, 2025
97b2e96
WP/DeprecatedFunctions: add tests for namespaced names
rodrigoprimo Aug 21, 2025
ae34825
Merge pull request #2581 from rodrigoprimo/add-abstract-function-rest…
jrfnl Sep 18, 2025
5765dae
Merge pull request #2572 from rodrigoprimo/nonce-verification-fix-fun…
dingo-d Sep 19, 2025
b4fa525
GH Actions: "pin" all action runners
jrfnl Sep 20, 2025
d5a0adc
Dependabot: update config
jrfnl Sep 20, 2025
4e78b7c
Merge pull request #2621 from WordPress/feature/ghactions-pin-action-…
GaryJones Sep 29, 2025
50492d6
GH Actions: Bump crate-ci/typos in the action-runners group
dependabot[bot] Sep 29, 2025
c2eff7f
Merge pull request #2624 from WordPress/dependabot/github_actions/act…
jrfnl Sep 29, 2025
9f0c6a8
GH Actions: do not persist credentials
jrfnl Sep 20, 2025
8e6628f
Merge pull request #2625 from WordPress/feature/ghactions-dont-persis…
GaryJones Sep 30, 2025
9d7da91
GH Actions: Bump crate-ci/typos in the action-runners group
dependabot[bot] Oct 6, 2025
fd195d8
Merge pull request #2627 from WordPress/dependabot/github_actions/act…
jrfnl Oct 6, 2025
526cd37
GH Actions: Bump crate-ci/typos in the action-runners group
dependabot[bot] Oct 13, 2025
a9c5c8f
Merge pull request #2629 from WordPress/dependabot/github_actions/act…
jrfnl Oct 14, 2025
e331fe6
WP/GetMetaSingle: simplify code using two class constants
rodrigoprimo Aug 5, 2025
a09975d
Fix version number in since tags
rodrigoprimo Oct 17, 2025
e53d4f9
Change the order of the two class constants
rodrigoprimo Oct 20, 2025
e3672da
Add `private` visibility to the two new constants
rodrigoprimo Oct 20, 2025
20b2c5a
Documentation: fix broken WordPress VIP links in sniff docblocks
rodrigoprimo Sep 17, 2024
9a6fe07
Merge pull request #2631 from rodrigoprimo/update-get-meta-single
GaryJones Oct 27, 2025
aa5bafa
GH Actions: Bump crate-ci/typos in the action-runners group
dependabot[bot] Nov 3, 2025
b2e3d0f
Merge pull request #2638 from WordPress/dependabot/github_actions/act…
jrfnl Nov 4, 2025
4639b05
Security/ValidatedSanitizedInput: improve `InputNotValidated` error m…
rodrigoprimo Nov 6, 2025
882af07
Merge pull request #2642 from rodrigoprimo/update-validated-sanitized…
dingo-d Nov 7, 2025
bb822fe
Merge pull request #2637 from rodrigoprimo/fix-vip-links
jrfnl Nov 10, 2025
e60764e
Utils/I18nTextDomainFixer: add tests for namespaced names
rodrigoprimo Aug 19, 2025
b39cffc
Security/NonceVerification: add tests for namespaced names
rodrigoprimo Aug 21, 2025
a8d703c
NamingConventions/ValidHookName: add tests for namespaced names
rodrigoprimo Aug 21, 2025
269da1b
NamingConventions/PrefixAllGlobals: add tests for namespaced names
rodrigoprimo Aug 21, 2025
4a34f38
PHP/NoSilencedErrors: add tests for namespaced names
rodrigoprimo Aug 21, 2025
861c0e8
WP/CronInterval: add tests for namespaced names
rodrigoprimo Aug 21, 2025
b86f078
WP/DiscouragedConstants: add tests for namespaced function calls
rodrigoprimo Aug 18, 2025
22e4f55
WP/EnqueuedResourceParameters: fix some inaccuracies and typos in cod…
rodrigoprimo Oct 15, 2025
c7c7e2d
WP/EnqueuedResourceParameters: fix handling of non-lowercased `null`
rodrigoprimo Oct 15, 2025
668eed5
Composer: raise the minimum supported PHPCS version to 3.13.4
rodrigoprimo Oct 20, 2025
e0dd5d5
WP/EnqueuedResourceParameters: handle fully qualified `\false` and `\…
rodrigoprimo Aug 14, 2025
8fe987c
Merge pull request #2630 from rodrigoprimo/enqueued-resource-paramete…
dingo-d Nov 13, 2025
282727a
DB/DirectDatabaseQuery: add tests for namespaced names
rodrigoprimo Aug 7, 2025
08c3d1b
Composer: update to PHPCSExtra 1.5.0
jrfnl Nov 16, 2025
2be483c
WordPress-Extra: add some sniffs related to attribute formatting
jrfnl Nov 16, 2025
262b65a
Merge pull request #2646 from WordPress/feature/updates-for-phpcsextr…
GaryJones Nov 16, 2025
c41a317
Merge pull request #2620 from rodrigoprimo/more-namespace-tests
dingo-d Nov 17, 2025
efc5582
GH Actions: update for the release of PHP 8.5
jrfnl Nov 18, 2025
f2a4a1c
GH Actions: Bump the action-runners group with 2 updates
dependabot[bot] Nov 18, 2025
73c5152
Merge pull request #2650 from WordPress/dependabot/github_actions/act…
jrfnl Nov 18, 2025
a54427a
CS: start using PHPCompatibility 10
jrfnl Nov 23, 2025
638dbce
Merge pull request #2619 from rodrigoprimo/direct-database-query-name…
dingo-d Nov 23, 2025
b207c17
NamingConventions/PrefixAllGlobals: update the functions list based o…
jrfnl Nov 23, 2025
5bb8db0
WP/ClassNameCase: update the class lists based on WP 6.9.0-RC2
jrfnl Nov 23, 2025
48a519f
WP/DeprecatedFunctions: update the functions list based on WP 6.9.0-RC2
jrfnl Nov 23, 2025
75539a4
WP/DeprecatedParameters: update the functions list based on WP 6.9.0-RC2
jrfnl Nov 23, 2025
5ffaf4a
Various sniffs: update docs
jrfnl Nov 23, 2025
1f16cb6
GH Actions: improve "don't run on forks" conditions
jrfnl Nov 23, 2025
13e2eda
DB/DirectDatabaseQuery: allow for more caching functions
jrfnl Nov 23, 2025
e2e4d2a
GH Actions: Bump actions/checkout from 5.0.1 to 6.0.0
dependabot[bot] Nov 24, 2025
d0d8da5
Merge pull request #2655 from WordPress/dependabot/github_actions/act…
jrfnl Nov 24, 2025
2e47aad
Merge pull request #2649 from WordPress/feature/ghactions-update-for-…
GaryJones Nov 24, 2025
3ef3f9d
Merge pull request #2652 from WordPress/feature/update-for-wp-6.9
GaryJones Nov 24, 2025
76eeb61
Merge pull request #2653 from WordPress/feature/ghactions-improve-don…
GaryJones Nov 24, 2025
7f36b9d
Update the minimum_wp_version to WP 6.6
jrfnl Nov 23, 2025
7629477
Merge pull request #2651 from WordPress/feature/use-phpcompatibility-…
GaryJones Nov 24, 2025
da2054d
Merge pull request #2654 from WordPress/feature/directdatabasequery-u…
jrfnl Nov 24, 2025
12e2936
Changelog for the release of WordPressCS 3.3.0
jrfnl Nov 23, 2025
c2b30bf
Merge pull request #2656 from WordPress/feature/update-minimum-wp-ver…
dingo-d Nov 25, 2025
5025d83
Merge pull request #2657 from WordPress/feature/changelog-3.3.0
dingo-d Nov 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 82 additions & 58 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Contributing to the WordPress Coding Standards

Hi, thank you for your interest in contributing to the WordPress Coding Standards! We look forward to working with you.

# Reporting Bugs
## Reporting Bugs

Please search the repo to see if your issue has been reported already and if so, comment in that issue instead of opening a new one.

Expand All @@ -9,48 +11,69 @@ Running `phpcs` with the `-s` flag will show the name of the sniff with each err

Bug reports containing a minimal code sample which can be used to reproduce the issue are highly appreciated as those are most easily actionable.

## Upstream Issues
### Upstream Issues

Since WordPressCS employs many sniffs that are part of PHP_CodeSniffer itself or PHPCSExtra, sometimes an issue will be caused by a bug in PHPCS or PHPCSExtra and not in WordPressCS itself.
If the error message in question doesn't come from a sniff whose name starts with `WordPress`, the issue is probably a bug in PHPCS or PHPCSExtra.

* Bugs for sniffs starting with `Generic`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend` should be [reported to PHPCS](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues).
* Bugs for sniffs starting with `Modernize`, `NormalizedArrays` or `Universal` should be [reported to PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/issues).

# Contributing patches and new features
## Contributing patches and new features

### Tips for Successful PRs

We welcome contributions from everyone, and want your PR to have the best chance of being reviewed and merged. To help with this, please keep the following in mind:

* **Respect copyright and licensing.**
Only submit code that you have written yourself or that comes from sources where the license clearly allows inclusion. Submitting code that infringes on copyright or licensing terms puts both you and the project at legal risk, and such contributions cannot be accepted.

* **Do not submit AI-generated code.**
Pull requests containing AI-generated code are not acceptable. Beyond copyright and licensing uncertainties, AI-generated contributions consistently require disproportionate amounts of maintainer time to review, correct, or rewrite. This wastes limited project resources and slows progress for everyone. Submitting AI-generated code may be treated as a violation of our [Code of Conduct](../CODE_OF_CONDUCT.md).

## Branches
* **Focus on quality and clarity.**
Take time to explain *why* the change is needed, and include tests or examples where appropriate. Clear, self-written explanations make it more straightforward for reviewers to understand what you are trying to achieve.

* **Think about long-term maintainability.**
Code should align with WordPress Coding Standards and be written in a way that others can readily read, understand, and maintain.

* **Be collaborative.**
If you're unsure about an approach, open an issue first to start a conversation.

By following these tips, you'll save time for both yourself and the maintainers — and increase the likelihood that your contribution can be merged smoothly.

### Branches

Ongoing development will be done in the `develop` branch with merges to `main` once considered stable.

To contribute an improvement to this project, fork the repo, run `composer install`, make your changes to the code, run the unit tests and code style checks by running `composer check-all`, and if all is good, open a pull request to the `develop` branch.
Alternatively, if you have push access to this repo, create a feature branch prefixed by `feature/` and then open an intra-repo PR from that branch to `develop`.

# Considerations when writing sniffs
## Considerations when writing sniffs

## Public properties
### Public properties

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

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.

# Unit Testing
## Unit Testing

## Pre-requisites
### Pre-requisites
* WordPress-Coding-Standards
* PHP_CodeSniffer 3.13.0 or higher
* PHP_CodeSniffer 3.13.4 or higher
* PHPCSUtils 1.1.0 or higher
* PHPCSExtra 1.4.0 or higher
* PHPUnit 4.x - 9.x
* PHPCSExtra 1.5.0 or higher
* PHPUnit 8.x - 9.x

The WordPress Coding Standards use the `PHP_CodeSniffer` native unit test framework for unit testing the sniffs.

## Getting ready to test
### Getting ready to test

Presuming you have cloned WordPressCS for development, to run the unit tests you need to make sure you have run `composer install` from the root directory of your WordPressCS git clone.

## Custom develop setups
### Custom develop setups

If you are developing with a stand-alone PHP_CodeSniffer (git clone) installation and want to use that git clone to test WordPressCS, there are three extra things you need to do:
1. Install [PHPCSUtils](https://github.com/PHPCSStandards/PHPCSUtils).
Expand All @@ -73,7 +96,7 @@ If you are developing with a stand-alone PHP_CodeSniffer (git clone) installatio
</php>
```
## Running the unit tests
### Running the unit tests
From the root of your WordPressCS install, run the unit tests like so:
```bash
Expand All @@ -85,32 +108,32 @@ phpunit --filter WordPress /path/to/PHP_CodeSniffer/tests/AllTests.php
Expected output:
```
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.
PHPUnit 9.6.26 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.0
Runtime: PHP 8.4.12
Configuration: /WordPressCS/phpunit.xml.dist
......................................................... 57 / 57 (100%)
............................................................ 60 / 60 (100%)
201 sniff test files generated 744 unique error codes; 50 were fixable (6%)
210 sniff test files generated 775 unique error codes; 50 were fixable (6%)
Time: 10.19 seconds, Memory: 40.00 MB
Time: 00:03.396, Memory: 60.00 MB
OK (57 tests, 0 assertions)
OK (60 tests, 6 assertions)
```
## Unit Testing conventions
### Unit Testing conventions
If you look inside the `WordPress/Tests` subdirectory, you'll see the structure mimics the `WordPress/Sniffs` subdirectory structure. For example, the `WordPress/Sniffs/PHP/POSIXFunctionsSniff.php` sniff has its unit test class defined in `WordPress/Tests/PHP/POSIXFunctionsUnitTest.php` which checks the `WordPress/Tests/PHP/POSIXFunctionsUnitTest.inc` test case file. See the file naming convention?
If you look inside the `WordPress/Tests` subdirectory, you'll see the structure mimics the `WordPress/Sniffs` subdirectory structure. For example, the `WordPress/Sniffs/PHP/TypeCastsSniff.php` sniff has its unit test class defined in `WordPress/Tests/PHP/TypeCastsUnitTest.php` which checks the `WordPress/Tests/PHP/TypeCastsUnitTest.inc` test case file. See the file naming convention?

Lets take a look at what's inside `POSIXFunctionsUnitTest.php`:
Lets take a look at what's inside `TypeCastsUnitTest.php`:
```php
namespace WordPressCS\WordPress\Tests\PHP;
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
final class POSIXFunctionsUnitTest extends AbstractSniffUnitTest {
final class TypeCastsUnitTest extends AbstractSniffUnitTest {
/**
* Returns the lines where errors should occur.
Expand All @@ -119,58 +142,59 @@ final class POSIXFunctionsUnitTest extends AbstractSniffUnitTest {
*/
public function getErrorList() {
return array(
10 => 1,
11 => 1,
13 => 1,
16 => 1,
18 => 1,
20 => 1,
22 => 1,
24 => 1,
26 => 1,
27 => 1,
28 => 1,
);
}
...
}
```
Also note the class name convention. The method `getErrorList()` MUST return an array of line numbers indicating errors (when running `phpcs`) found in `WordPress/Tests/PHP/POSIXFunctionsUnitTest.inc`. Similarly, the `getWarningList()` method must return an array of line numbers with the number of expected warnings.
Also note the class name convention. The method `getErrorList()` MUST return an array of line numbers indicating errors (when running `phpcs`) found in `WordPress/Tests/PHP/TypeCastsUnitTest.inc`. Similarly, the `getWarningList()` method must return an array of line numbers with the number of expected warnings.
If you run the following from the root directory of your WordPressCS clone:
```sh
$ "vendor/bin/phpcs" --standard=Wordpress -s ./WordPress/Tests/PHP/POSIXFunctionsUnitTest.inc --sniffs=WordPress.PHP.POSIXFunctions
...
--------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 7 LINES
--------------------------------------------------------------------------------
13 | ERROR | ereg() has been deprecated since PHP 5.3 and removed in PHP 7.0,
| | please use preg_match() instead.
| | (WordPress.PHP.POSIXFunctions.ereg_ereg)
16 | ERROR | eregi() has been deprecated since PHP 5.3 and removed in PHP 7.0,
| | please use preg_match() instead.
| | (WordPress.PHP.POSIXFunctions.ereg_eregi)
18 | ERROR | ereg_replace() has been deprecated since PHP 5.3 and removed in
| | PHP 7.0, please use preg_replace() instead.
| | (WordPress.PHP.POSIXFunctions.ereg_replace_ereg_replace)
20 | ERROR | eregi_replace() has been deprecated since PHP 5.3 and removed in
| | PHP 7.0, please use preg_replace() instead.
| | (WordPress.PHP.POSIXFunctions.ereg_replace_eregi_replace)
22 | ERROR | split() has been deprecated since PHP 5.3 and removed in PHP 7.0,
| | please use explode(), str_split() or preg_split() instead.
| | (WordPress.PHP.POSIXFunctions.split_split)
24 | ERROR | spliti() has been deprecated since PHP 5.3 and removed in PHP
| | 7.0, please use explode(), str_split() or preg_split()
| | instead. (WordPress.PHP.POSIXFunctions.split_spliti)
26 | ERROR | sql_regcase() has been deprecated since PHP 5.3 and removed in
| | PHP 7.0, please use preg_match() instead.
| | (WordPress.PHP.POSIXFunctions.ereg_sql_regcase)
--------------------------------------------------------------------------------
$ "vendor/bin/phpcs" --standard=Wordpress -s ./WordPress/Tests/PHP/TypeCastsUnitTest.inc --sniffs=WordPress.PHP.TypeCasts
...
----------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 4 WARNINGS AFFECTING 10 LINES
----------------------------------------------------------------------------------------------------
10 | ERROR | [x] Normalized type keywords must be used; expected "(float)" but found "(double)"
| | (WordPress.PHP.TypeCasts.DoubleRealFound)
11 | ERROR | [x] Normalized type keywords must be used; expected "(float)" but found "(real)"
| | (WordPress.PHP.TypeCasts.DoubleRealFound)
13 | ERROR | [ ] Using the "(unset)" cast is forbidden as the type cast is removed in PHP 8.0.
| | Use the "unset()" language construct instead.
| | (WordPress.PHP.TypeCasts.UnsetFound)
15 | WARNING | [ ] Using binary casting is strongly discouraged. Found: "(binary)"
| | (WordPress.PHP.TypeCasts.BinaryFound)
16 | WARNING | [ ] Using binary casting is strongly discouraged. Found: "b"
| | (WordPress.PHP.TypeCasts.BinaryFound)
17 | WARNING | [ ] Using binary casting is strongly discouraged. Found: "b"
| | (WordPress.PHP.TypeCasts.BinaryFound)
26 | ERROR | [x] Normalized type keywords must be used; expected "(float)" but found "(double)"
| | (WordPress.PHP.TypeCasts.DoubleRealFound)
27 | ERROR | [x] Normalized type keywords must be used; expected "(float)" but found "(real)"
| | (WordPress.PHP.TypeCasts.DoubleRealFound)
28 | ERROR | [ ] Using the "(unset)" cast is forbidden as the type cast is removed in PHP 8.0.
| | Use the "unset()" language construct instead.
| | (WordPress.PHP.TypeCasts.UnsetFound)
29 | WARNING | [ ] Using binary casting is strongly discouraged. Found: "(binary)"
| | (WordPress.PHP.TypeCasts.BinaryFound)
----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------
```
You'll see the line number and number of ERRORs we need to return in the `getErrorList()` method.

The `--sniffs=...` directive limits the output to the sniff you are testing.

## Code Standards for this project
### Code Standards for this project

The sniffs and test files - not test _case_ files! - for WordPressCS should be written such that they pass the `WordPress-Extra` and the `WordPress-Docs` code standards using the custom ruleset as found in `/.phpcs.xml.dist`.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ updates:
prefix: "GH Actions:"
labels:
- "Type: Chores/Cleanup"
groups:
action-runners:
applies-to: version-updates
update-types:
- "minor"
- "patch"
34 changes: 34 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!-- Provide a general summary of your changes in the title above. -->

<!--
============================================================================================
Please read the CONTRIBUTING guide before submitting your pull request.

- Warning: AI-generated PRs are NOT welcome and may result in a ban from this repository.
- Small PRs using atomic, descriptive commits are hugely appreciated, as it will make
reviewing your changes easier for the maintainers.
- Ensure that the code you are submitting meets copyright and licensing requirements to be included in this codebase.

Also, please make sure your pull request passes all continuous integration checks.
PRs which are failing their CI checks will likely be ignored by the maintainers.

============================================================================================
-->

# Description
<!--
What problem does this PR solve?
Describe the purpose of your changes in detail explaining which choices you have made and why.
-->


## Suggested changelog entry
<!--
Please provide a short description of the change for the changelog.
See the https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/CHANGELOG.md file if you need examples.
-->


## Related issues/external references

Fixes #
14 changes: 9 additions & 5 deletions .github/release-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ PR for tracking changes for the x.x.x release. Target release date: **DOW MONTH

### Release prep

- [ ] Double-check that all PRs which were merged since the last release have a milestone attached to it.
- [ ] Add changelog for the release - PR #xxx
:pencil2: Remember to add a release link at the bottom!
- [ ] Update `README` (if applicable) - PR #xxx
Expand All @@ -45,7 +46,7 @@ PR for tracking changes for the x.x.x release. Target release date: **DOW MONTH

- [ ] Merge this PR.
- [ ] Make sure all CI builds are green.
- [ ] Tag and create a release against `main` (careful, GH defaults to `develop`!) & copy & paste the changelog to it.
- [ ] Tag and create a release against `main` (careful, GH defaults to `develop`!) & copy & paste the changelog to it.
:pencil2: Check if anything from the link collection at the bottom of the changelog needs to be copied in!
- Remove square brackets from all ticket links or make them proper full links (as GH markdown parser doesn't parse these correctly).
- Change all contributor links to full inline links (as GH markdown parser on the Releases page doesn't parse these correctly).
Expand All @@ -62,13 +63,16 @@ PR for tracking changes for the x.x.x release. Target release date: **DOW MONTH
### Publicize

- [ ] [Major releases only] Publish post about the release on Make WordPress.
- [ ] Tweet, toot, etc about the release.
- [ ] Post about it in Slack.
- [ ] Submit for ["Month in WordPress"][month-in-wp].
- [ ] Tweet, toot, etc about the release from your personal account (there is no official WPCS account).
- [ ] Post about it in #core channel on the WordPress.org Slack.
:pencil2: No need to post in the #core-coding-standard channel as that gets an automated release notification anyway.
- [ ] Optionally post in #plugin-review if a sniff was added in a release which was requested by the plugin review team.
- [ ] Optionally post in #core-docs if significant updates were made to the documentation ruleset.
- [ ] Create a Marketing team ["amplify request"][amplify-request].
- [ ] Submit for the ["Monthy Dev Roundup"][dev-roundup].

[phpcs-releases]: https://github.com/PHPCSStandards/PHP_CodeSniffer/releases
[phpcsutils-releases]: https://github.com/PHPCSStandards/PHPCSUtils/releases
[phpcsextra-releases]: https://github.com/PHPCSStandards/PHPCSExtra/releases
[month-in-wp]: https://make.wordpress.org/community/month-in-wordpress-submissions/
[amplify-request]: https://github.com/WordPress/Marketing-Team/issues/new?template=2-request-for-amplification-template.yml
[dev-roundup]: https://github.com/WordPress/developer-blog-content/issues?q=is%3Aissue+label%3A%22Monthly+Roundup%22
Loading
Loading