Skip to content

Commit d2421de

Browse files
authored
Merge pull request #2558 from WordPress/develop
Release WordPressCS 3.2.0
2 parents 9333efc + d0140c8 commit d2421de

File tree

114 files changed

+1517
-385
lines changed

Some content is hidden

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

114 files changed

+1517
-385
lines changed

.github/CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ 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

3838
# Unit Testing
3939

4040
## Pre-requisites
4141
* WordPress-Coding-Standards
42-
* PHP_CodeSniffer 3.9.0 or higher
43-
* PHPCSUtils 1.0.10 or higher
44-
* PHPCSExtra 1.2.1 or higher
42+
* PHP_CodeSniffer 3.13.0 or higher
43+
* PHPCSUtils 1.1.0 or higher
44+
* PHPCSExtra 1.4.0 or higher
4545
* PHPUnit 4.x - 9.x
4646

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

.github/release-checklist.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ PR for tracking changes for the x.x.x release. Target release date: **DOW MONTH
3232
- [ ] `$wp_time_constants` in `WordPress.WP.CronInterval` - PR #xxx
3333
- [ ] `$known_test_classes` in `IsUnitTestTrait` - PR #xxx
3434
- [ ] ...etc...
35+
- [ ] Verify there there has been no vandalism on the wiki (and if so, remove/fix it).
3536

3637
### Release prep
3738

@@ -46,6 +47,8 @@ PR for tracking changes for the x.x.x release. Target release date: **DOW MONTH
4647
- [ ] Make sure all CI builds are green.
4748
- [ ] Tag and create a release against `main` (careful, GH defaults to `develop`!) & copy & paste the changelog to it.
4849
:pencil2: Check if anything from the link collection at the bottom of the changelog needs to be copied in!
50+
- Remove square brackets from all ticket links or make them proper full links (as GH markdown parser doesn't parse these correctly).
51+
- Change all contributor links to full inline links (as GH markdown parser on the Releases page doesn't parse these correctly).
4952
- [ ] Make sure all CI builds are green.
5053
- [ ] Close the milestone.
5154
- [ ] Open a new milestone for the next release.

.github/workflows/basic-qa.yml

Lines changed: 79 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ jobs:
2424
name: Run code sniffs
2525
runs-on: ubuntu-latest
2626

27-
env:
28-
XMLLINT_INDENT: ' '
29-
3027
steps:
3128
- name: Checkout repository
3229
uses: actions/checkout@v4
@@ -56,16 +53,6 @@ jobs:
5653
# Bust the cache at least once a month - output format: YYYY-MM.
5754
custom-cache-suffix: $(date -u "+%Y-%m")
5855

59-
- name: Install xmllint
60-
run: |
61-
sudo apt-get update
62-
sudo apt-get install --no-install-recommends -y libxml2-utils
63-
64-
# Show XML violations inline in the file diff.
65-
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
66-
- name: Enable showing XML issues inline
67-
uses: korelstar/xmllint-problem-matcher@v1
68-
6956
- name: Check the code style of the PHP files
7057
id: phpcs
7158
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml
@@ -77,14 +64,72 @@ jobs:
7764
# Validate the Ruleset XML files.
7865
# @link http://xmlsoft.org/xmllint.html
7966
- name: Validate the WordPress rulesets
80-
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml
67+
uses: phpcsstandards/xmllint-validate@v1
68+
with:
69+
pattern: "./*/ruleset.xml"
70+
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
8171

8272
- name: Validate the sample ruleset
83-
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./phpcs.xml.dist.sample
73+
uses: phpcsstandards/xmllint-validate@v1
74+
with:
75+
pattern: "phpcs.xml.dist.sample"
76+
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
8477

8578
# Validate the Documentation XML files.
8679
- name: Validate documentation against schema
87-
run: xmllint --noout --schema vendor/phpcsstandards/phpcsdevtools/DocsXsd/phpcsdocs.xsd ./WordPress/Docs/*/*Standard.xml
80+
uses: phpcsstandards/xmllint-validate@v1
81+
with:
82+
pattern: "./WordPress/Docs/*/*Standard.xml"
83+
xsd-file: "vendor/phpcsstandards/phpcsdevtools/DocsXsd/phpcsdocs.xsd"
84+
85+
- name: Validate Project PHPCS ruleset against schema
86+
uses: phpcsstandards/xmllint-validate@v1
87+
with:
88+
pattern: ".phpcs.xml.dist"
89+
xsd-file: "vendor/squizlabs/php_codesniffer/phpcs.xsd"
90+
91+
- name: "Validate PHPUnit config for use with PHPUnit 8"
92+
uses: phpcsstandards/xmllint-validate@v1
93+
with:
94+
pattern: "phpunit.xml.dist"
95+
xsd-file: "vendor/phpunit/phpunit/schema/8.5.xsd"
96+
97+
- name: "Validate PHPUnit config for use with PHPUnit 9"
98+
uses: phpcsstandards/xmllint-validate@v1
99+
with:
100+
pattern: "phpunit.xml.dist"
101+
xsd-file: "vendor/phpunit/phpunit/schema/9.2.xsd"
102+
103+
# Check that the sniffs available are feature complete.
104+
# For now, just check that all sniffs have unit tests.
105+
# At a later stage the documentation check can be activated.
106+
- name: Check sniff feature completeness
107+
run: composer check-complete
108+
109+
xml-cs:
110+
name: 'XML Code style'
111+
runs-on: ubuntu-latest
112+
113+
env:
114+
XMLLINT_INDENT: ' '
115+
116+
steps:
117+
- name: Checkout code
118+
uses: actions/checkout@v4
119+
120+
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
121+
# This should not be blocking for this job, so ignore any errors from this step.
122+
# Ref: https://github.com/dotnet/core/issues/4167
123+
- name: Update the available packages list
124+
continue-on-error: true
125+
run: sudo apt-get update
126+
127+
- name: Install xmllint
128+
run: sudo apt-get install --no-install-recommends -y libxml2-utils
129+
130+
# Show XML violations inline in the file diff.
131+
- name: Enable showing XML issues inline
132+
uses: korelstar/xmllint-problem-matcher@v1
88133

89134
- name: Check the code-style consistency of the xml files
90135
run: |
@@ -94,12 +139,6 @@ jobs:
94139
diff -B --tabsize=4 ./WordPress-Extra/ruleset.xml <(xmllint --format "./WordPress-Extra/ruleset.xml")
95140
diff -B --tabsize=4 ./phpcs.xml.dist.sample <(xmllint --format "./phpcs.xml.dist.sample")
96141
97-
# Check that the sniffs available are feature complete.
98-
# For now, just check that all sniffs have unit tests.
99-
# At a later stage the documentation check can be activated.
100-
- name: Check sniff feature completeness
101-
run: composer check-complete
102-
103142
# Makes sure the rulesets don't throw unexpected errors or warnings.
104143
# This workflow needs to be run against a high PHP version to prevent triggering the syntax error check.
105144
# It also needs to be run against all dependency versions WPCS is tested against.
@@ -132,6 +171,10 @@ jobs:
132171
phpcsstandards/phpcsutils:"${{ env.UTILS_DEV }}"
133172
phpcsstandards/phpcsextra:"${{ env.EXTRA_DEV }}"
134173
174+
- name: Enable creation of `composer.lock` file
175+
if: ${{ matrix.dependencies == 'lowest' }}
176+
run: composer config --unset lock
177+
135178
- name: Install Composer dependencies
136179
uses: ramsey/composer-install@v3
137180
with:
@@ -177,7 +220,7 @@ jobs:
177220
set +e
178221
$(pwd)/vendor/bin/phpcbf -pq ./WordPress/Tests/ --standard=WordPress --extensions=inc --exclude=Generic.PHP.Syntax --report=summary --ignore=/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.7.inc
179222
exitcode="$?"
180-
echo "EXITCODE=$exitcode" >> $GITHUB_OUTPUT
223+
echo "EXITCODE=$exitcode" >> "$GITHUB_OUTPUT"
181224
exit "$exitcode"
182225
183226
- name: Fail the build on fixer conflicts and other errors
@@ -198,7 +241,7 @@ jobs:
198241
with:
199242
php-version: 'latest'
200243
coverage: none
201-
tools: phpstan
244+
tools: phpstan:1.x
202245

203246
# Install dependencies and handle caching in one go.
204247
# Dependencies need to be installed to make sure the PHPCS and PHPUnit classes are recognized.
@@ -211,3 +254,15 @@ jobs:
211254

212255
- name: Run PHPStan
213256
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"

.github/workflows/quicktest.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ jobs:
4141
ini-values: error_reporting=-1, display_errors=On
4242
coverage: ${{ github.ref_name == 'develop' && 'xdebug' || 'none' }}
4343

44+
- name: Enable creation of `composer.lock` file
45+
if: ${{ matrix.dependencies == 'lowest' }}
46+
run: composer config --unset lock
47+
4448
- name: Install Composer dependencies
4549
uses: ramsey/composer-install@v3
4650
with:
@@ -60,17 +64,19 @@ jobs:
6064
run: composer lint
6165

6266
- name: Run the unit tests without code coverage
63-
if: ${{ github.ref_name != 'develop' }}
67+
if: ${{ github.repository_owner != 'WordPress' || github.ref_name != 'develop' }}
6468
run: composer run-tests
6569

6670
- name: Run the unit tests with code coverage
67-
if: ${{ github.ref_name == 'develop' }}
71+
if: ${{ github.repository_owner == 'WordPress' && github.ref_name == 'develop' }}
6872
run: composer coverage
6973

7074
- name: Send coverage report to Codecov
71-
if: ${{ success() && github.ref_name == 'develop' }}
72-
uses: codecov/codecov-action@v3
75+
if: ${{ success() && github.repository_owner == 'WordPress' && github.ref_name == 'develop' }}
76+
uses: codecov/codecov-action@v5
7377
with:
7478
files: ./build/logs/clover.xml
7579
fail_ci_if_error: true
7680
verbose: true
81+
env:
82+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/unit-tests.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727
strategy:
2828
matrix:
29-
php: [ '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.4' ]
29+
php: [ '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.5' ]
3030
dependencies: [ 'lowest', 'stable' ]
3131
extensions: [ '' ]
3232
coverage: [false]
@@ -46,11 +46,11 @@ jobs:
4646
dependencies: 'lowest'
4747
extensions: ''
4848
coverage: true
49-
- php: '8.3'
49+
- php: '8.4'
5050
dependencies: 'stable'
5151
extensions: ''
5252
coverage: true
53-
- php: '8.3'
53+
- php: '8.4'
5454
dependencies: 'lowest'
5555
extensions: ''
5656
coverage: true
@@ -68,18 +68,18 @@ jobs:
6868
dependencies: 'dev'
6969
extensions: ''
7070
coverage: false
71-
- php: '8.3'
71+
- php: '8.4'
7272
dependencies: 'dev'
7373
extensions: ''
7474
coverage: false
7575

7676
# Add extra build to test against PHPCS 4.
7777
#- php: '7.4'
78-
# dependencies: '4.0.x-dev as 3.9.99'
78+
# dependencies: '4.0.x-dev as 3.99.99'
7979

8080
name: PHP ${{ matrix.php }} on PHPCS ${{ matrix.dependencies }}
8181

82-
continue-on-error: ${{ matrix.php == '8.4' }}
82+
continue-on-error: ${{ matrix.php == '8.5' }}
8383

8484
steps:
8585
- name: Checkout repository
@@ -91,9 +91,9 @@ jobs:
9191
id: set_ini
9292
run: |
9393
if [ "${{ matrix.dependencies }}" != "dev" ]; then
94-
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> $GITHUB_OUTPUT
94+
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> "$GITHUB_OUTPUT"
9595
else
96-
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
96+
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> "$GITHUB_OUTPUT"
9797
fi
9898
9999
- name: Set up PHP
@@ -112,6 +112,10 @@ jobs:
112112
phpcsstandards/phpcsutils:"${{ env.UTILS_DEV }}"
113113
phpcsstandards/phpcsextra:"${{ env.EXTRA_DEV }}"
114114
115+
- name: Enable creation of `composer.lock` file
116+
if: ${{ matrix.dependencies == 'lowest' }}
117+
run: composer config --unset lock
118+
115119
- name: Install Composer dependencies
116120
uses: ramsey/composer-install@v3
117121
with:
@@ -140,8 +144,10 @@ jobs:
140144

141145
- name: Send coverage report to Codecov
142146
if: ${{ success() && matrix.coverage == true }}
143-
uses: codecov/codecov-action@v3
147+
uses: codecov/codecov-action@v5
144148
with:
145149
files: ./build/logs/clover.xml
146150
fail_ci_if_error: true
147151
verbose: true
152+
env:
153+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Coding Standards" xsi:noNamespaceSchemaLocation="https://schema.phpcodesniffer.com/phpcs.xsd">
33

44
<description>The Coding standard for the WordPress Coding Standards itself.</description>
55

0 commit comments

Comments
 (0)