Skip to content

Commit 7795ec6

Browse files
authored
Merge pull request #2658 from WordPress/develop
Release WordPressCS 3.3.0
2 parents d2421de + 5025d83 commit 7795ec6

File tree

113 files changed

+1782
-677
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1782
-677
lines changed

.github/CONTRIBUTING.md

Lines changed: 82 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# Contributing to the WordPress Coding Standards
2+
13
Hi, thank you for your interest in contributing to the WordPress Coding Standards! We look forward to working with you.
24

3-
# Reporting Bugs
5+
## Reporting Bugs
46

57
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.
68

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

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

12-
## Upstream Issues
14+
### Upstream Issues
1315

1416
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.
1517
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.
1618

1719
* 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).
1820
* Bugs for sniffs starting with `Modernize`, `NormalizedArrays` or `Universal` should be [reported to PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/issues).
1921

20-
# Contributing patches and new features
22+
## Contributing patches and new features
23+
24+
### Tips for Successful PRs
25+
26+
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:
27+
28+
* **Respect copyright and licensing.**
29+
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.
30+
31+
* **Do not submit AI-generated code.**
32+
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).
2133

22-
## Branches
34+
* **Focus on quality and clarity.**
35+
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.
36+
37+
* **Think about long-term maintainability.**
38+
Code should align with WordPress Coding Standards and be written in a way that others can readily read, understand, and maintain.
39+
40+
* **Be collaborative.**
41+
If you're unsure about an approach, open an issue first to start a conversation.
42+
43+
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.
44+
45+
### Branches
2346

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

2649
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.
2750
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`.
2851

29-
# Considerations when writing sniffs
52+
## Considerations when writing sniffs
3053

31-
## Public properties
54+
### Public properties
3255

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

3659
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.
3760

38-
# Unit Testing
61+
## Unit Testing
3962

40-
## Pre-requisites
63+
### Pre-requisites
4164
* WordPress-Coding-Standards
42-
* PHP_CodeSniffer 3.13.0 or higher
65+
* PHP_CodeSniffer 3.13.4 or higher
4366
* PHPCSUtils 1.1.0 or higher
44-
* PHPCSExtra 1.4.0 or higher
45-
* PHPUnit 4.x - 9.x
67+
* PHPCSExtra 1.5.0 or higher
68+
* PHPUnit 8.x - 9.x
4669

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

49-
## Getting ready to test
72+
### Getting ready to test
5073

5174
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.
5275

53-
## Custom develop setups
76+
### Custom develop setups
5477

5578
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:
5679
1. Install [PHPCSUtils](https://github.com/PHPCSStandards/PHPCSUtils).
@@ -73,7 +96,7 @@ If you are developing with a stand-alone PHP_CodeSniffer (git clone) installatio
7396
</php>
7497
```
7598
76-
## Running the unit tests
99+
### Running the unit tests
77100
78101
From the root of your WordPressCS install, run the unit tests like so:
79102
```bash
@@ -85,32 +108,32 @@ phpunit --filter WordPress /path/to/PHP_CodeSniffer/tests/AllTests.php
85108
86109
Expected output:
87110
```
88-
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.
111+
PHPUnit 9.6.26 by Sebastian Bergmann and contributors.
89112
90-
Runtime: PHP 8.3.0
113+
Runtime: PHP 8.4.12
91114
Configuration: /WordPressCS/phpunit.xml.dist
92115
93-
......................................................... 57 / 57 (100%)
116+
............................................................ 60 / 60 (100%)
94117
95-
201 sniff test files generated 744 unique error codes; 50 were fixable (6%)
118+
210 sniff test files generated 775 unique error codes; 50 were fixable (6%)
96119
97-
Time: 10.19 seconds, Memory: 40.00 MB
120+
Time: 00:03.396, Memory: 60.00 MB
98121
99-
OK (57 tests, 0 assertions)
122+
OK (60 tests, 6 assertions)
100123
```
101124
102-
## Unit Testing conventions
125+
### Unit Testing conventions
103126
104-
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?
127+
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?
105128

106-
Lets take a look at what's inside `POSIXFunctionsUnitTest.php`:
129+
Lets take a look at what's inside `TypeCastsUnitTest.php`:
107130
108131
```php
109132
namespace WordPressCS\WordPress\Tests\PHP;
110133
111134
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
112135
113-
final class POSIXFunctionsUnitTest extends AbstractSniffUnitTest {
136+
final class TypeCastsUnitTest extends AbstractSniffUnitTest {
114137
115138
/**
116139
* Returns the lines where errors should occur.
@@ -119,58 +142,59 @@ final class POSIXFunctionsUnitTest extends AbstractSniffUnitTest {
119142
*/
120143
public function getErrorList() {
121144
return array(
145+
10 => 1,
146+
11 => 1,
122147
13 => 1,
123-
16 => 1,
124-
18 => 1,
125-
20 => 1,
126-
22 => 1,
127-
24 => 1,
128148
26 => 1,
149+
27 => 1,
150+
28 => 1,
129151
);
130152
}
131153
132154
...
133155
}
134156
```
135157
136-
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.
158+
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.
137159
138160
If you run the following from the root directory of your WordPressCS clone:
139161
140162
```sh
141-
$ "vendor/bin/phpcs" --standard=Wordpress -s ./WordPress/Tests/PHP/POSIXFunctionsUnitTest.inc --sniffs=WordPress.PHP.POSIXFunctions
142-
...
143-
--------------------------------------------------------------------------------
144-
FOUND 7 ERRORS AFFECTING 7 LINES
145-
--------------------------------------------------------------------------------
146-
13 | ERROR | ereg() has been deprecated since PHP 5.3 and removed in PHP 7.0,
147-
| | please use preg_match() instead.
148-
| | (WordPress.PHP.POSIXFunctions.ereg_ereg)
149-
16 | ERROR | eregi() has been deprecated since PHP 5.3 and removed in PHP 7.0,
150-
| | please use preg_match() instead.
151-
| | (WordPress.PHP.POSIXFunctions.ereg_eregi)
152-
18 | ERROR | ereg_replace() has been deprecated since PHP 5.3 and removed in
153-
| | PHP 7.0, please use preg_replace() instead.
154-
| | (WordPress.PHP.POSIXFunctions.ereg_replace_ereg_replace)
155-
20 | ERROR | eregi_replace() has been deprecated since PHP 5.3 and removed in
156-
| | PHP 7.0, please use preg_replace() instead.
157-
| | (WordPress.PHP.POSIXFunctions.ereg_replace_eregi_replace)
158-
22 | ERROR | split() has been deprecated since PHP 5.3 and removed in PHP 7.0,
159-
| | please use explode(), str_split() or preg_split() instead.
160-
| | (WordPress.PHP.POSIXFunctions.split_split)
161-
24 | ERROR | spliti() has been deprecated since PHP 5.3 and removed in PHP
162-
| | 7.0, please use explode(), str_split() or preg_split()
163-
| | instead. (WordPress.PHP.POSIXFunctions.split_spliti)
164-
26 | ERROR | sql_regcase() has been deprecated since PHP 5.3 and removed in
165-
| | PHP 7.0, please use preg_match() instead.
166-
| | (WordPress.PHP.POSIXFunctions.ereg_sql_regcase)
167-
--------------------------------------------------------------------------------
163+
$ "vendor/bin/phpcs" --standard=Wordpress -s ./WordPress/Tests/PHP/TypeCastsUnitTest.inc --sniffs=WordPress.PHP.TypeCasts
168164
...
165+
----------------------------------------------------------------------------------------------------
166+
FOUND 6 ERRORS AND 4 WARNINGS AFFECTING 10 LINES
167+
----------------------------------------------------------------------------------------------------
168+
10 | ERROR | [x] Normalized type keywords must be used; expected "(float)" but found "(double)"
169+
| | (WordPress.PHP.TypeCasts.DoubleRealFound)
170+
11 | ERROR | [x] Normalized type keywords must be used; expected "(float)" but found "(real)"
171+
| | (WordPress.PHP.TypeCasts.DoubleRealFound)
172+
13 | ERROR | [ ] Using the "(unset)" cast is forbidden as the type cast is removed in PHP 8.0.
173+
| | Use the "unset()" language construct instead.
174+
| | (WordPress.PHP.TypeCasts.UnsetFound)
175+
15 | WARNING | [ ] Using binary casting is strongly discouraged. Found: "(binary)"
176+
| | (WordPress.PHP.TypeCasts.BinaryFound)
177+
16 | WARNING | [ ] Using binary casting is strongly discouraged. Found: "b"
178+
| | (WordPress.PHP.TypeCasts.BinaryFound)
179+
17 | WARNING | [ ] Using binary casting is strongly discouraged. Found: "b"
180+
| | (WordPress.PHP.TypeCasts.BinaryFound)
181+
26 | ERROR | [x] Normalized type keywords must be used; expected "(float)" but found "(double)"
182+
| | (WordPress.PHP.TypeCasts.DoubleRealFound)
183+
27 | ERROR | [x] Normalized type keywords must be used; expected "(float)" but found "(real)"
184+
| | (WordPress.PHP.TypeCasts.DoubleRealFound)
185+
28 | ERROR | [ ] Using the "(unset)" cast is forbidden as the type cast is removed in PHP 8.0.
186+
| | Use the "unset()" language construct instead.
187+
| | (WordPress.PHP.TypeCasts.UnsetFound)
188+
29 | WARNING | [ ] Using binary casting is strongly discouraged. Found: "(binary)"
189+
| | (WordPress.PHP.TypeCasts.BinaryFound)
190+
----------------------------------------------------------------------------------------------------
191+
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
192+
----------------------------------------------------------------------------------------------------
169193
```
170194
You'll see the line number and number of ERRORs we need to return in the `getErrorList()` method.
171195

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

174-
## Code Standards for this project
198+
### Code Standards for this project
175199

176200
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`.

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ updates:
1515
prefix: "GH Actions:"
1616
labels:
1717
- "Type: Chores/Cleanup"
18+
groups:
19+
action-runners:
20+
applies-to: version-updates
21+
update-types:
22+
- "minor"
23+
- "patch"

.github/pull_request_template.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!-- Provide a general summary of your changes in the title above. -->
2+
3+
<!--
4+
============================================================================================
5+
Please read the CONTRIBUTING guide before submitting your pull request.
6+
7+
- Warning: AI-generated PRs are NOT welcome and may result in a ban from this repository.
8+
- Small PRs using atomic, descriptive commits are hugely appreciated, as it will make
9+
reviewing your changes easier for the maintainers.
10+
- Ensure that the code you are submitting meets copyright and licensing requirements to be included in this codebase.
11+
12+
Also, please make sure your pull request passes all continuous integration checks.
13+
PRs which are failing their CI checks will likely be ignored by the maintainers.
14+
15+
============================================================================================
16+
-->
17+
18+
# Description
19+
<!--
20+
What problem does this PR solve?
21+
Describe the purpose of your changes in detail explaining which choices you have made and why.
22+
-->
23+
24+
25+
## Suggested changelog entry
26+
<!--
27+
Please provide a short description of the change for the changelog.
28+
See the https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/CHANGELOG.md file if you need examples.
29+
-->
30+
31+
32+
## Related issues/external references
33+
34+
Fixes #

.github/release-checklist.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ PR for tracking changes for the x.x.x release. Target release date: **DOW MONTH
3636

3737
### Release prep
3838

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

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

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

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

0 commit comments

Comments
 (0)