Skip to content

Commit 9333efc

Browse files
authored
Merge pull request #2439 from WordPress/develop
Release WordPressCS 3.1.0
2 parents b4caf96 + cf2cffe commit 9333efc

Some content is hidden

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

50 files changed

+496
-228
lines changed

.github/CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Bug reports containing a minimal code sample which can be used to reproduce the
1414
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.
1515
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.
1616

17-
* Bugs for sniffs starting with `Generic`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend` should be [reported to PHPCS](https://github.com/squizlabs/PHP_CodeSniffer/issues).
17+
* 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).
1818
* Bugs for sniffs starting with `Modernize`, `NormalizedArrays` or `Universal` should be [reported to PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/issues).
1919

2020
# Contributing patches and new features
@@ -39,10 +39,10 @@ When you introduce new `public` sniff properties, or your sniff extends a class
3939

4040
## Pre-requisites
4141
* WordPress-Coding-Standards
42-
* PHP_CodeSniffer 3.7.2 or higher
43-
* PHPCSUtils 1.0.8 or higher
44-
* PHPCSExtra 1.1.0 or higher
45-
* PHPUnit 4.x, 5.x, 6.x or 7.x
42+
* PHP_CodeSniffer 3.9.0 or higher
43+
* PHPCSUtils 1.0.10 or higher
44+
* PHPCSExtra 1.2.1 or higher
45+
* PHPUnit 4.x - 9.x
4646

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

@@ -85,9 +85,9 @@ phpunit --filter WordPress /path/to/PHP_CodeSniffer/tests/AllTests.php
8585
8686
Expected output:
8787
```
88-
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
88+
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.
8989
90-
Runtime: PHP 7.4.33
90+
Runtime: PHP 8.3.0
9191
Configuration: /WordPressCS/phpunit.xml.dist
9292
9393
......................................................... 57 / 57 (100%)
@@ -138,7 +138,7 @@ Also note the class name convention. The method `getErrorList()` MUST return an
138138
If you run the following from the root directory of your WordPressCS clone:
139139
140140
```sh
141-
$ "vendor/bin/phpcs" --standard=Wordpress -s ./Tests/PHP/POSIXFunctionsUnitTest.inc --sniffs=WordPress.PHP.POSIXFunctions
141+
$ "vendor/bin/phpcs" --standard=Wordpress -s ./WordPress/Tests/PHP/POSIXFunctionsUnitTest.inc --sniffs=WordPress.PHP.POSIXFunctions
142142
...
143143
--------------------------------------------------------------------------------
144144
FOUND 7 ERRORS AFFECTING 7 LINES

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
custom: "https://opencollective.com/thewpcc/contribute/wp-php-63406"
1+
custom: "https://opencollective.com/php_codesniffer"

.github/dependabot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Dependabot configuration.
2+
#
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
time: "09:00"
13+
open-pull-requests-limit: 5
14+
commit-message:
15+
prefix: "GH Actions:"
16+
labels:
17+
- "Type: Chores/Cleanup"

.github/release-checklist.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ PR for tracking changes for the x.x.x release. Target release date: **DOW MONTH
6464
- [ ] Submit for ["Month in WordPress"][month-in-wp].
6565
- [ ] Submit for the ["Monthy Dev Roundup"][dev-roundup].
6666

67-
[phpcs-releases]: https://github.com/squizlabs/PHP_CodeSniffer/releases
67+
[phpcs-releases]: https://github.com/PHPCSStandards/PHP_CodeSniffer/releases
6868
[phpcsutils-releases]: https://github.com/PHPCSStandards/PHPCSUtils/releases
6969
[phpcsextra-releases]: https://github.com/PHPCSStandards/PHPCSExtra/releases
7070
[month-in-wp]: https://make.wordpress.org/community/month-in-wordpress-submissions/

.github/workflows/basic-qa.yml

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ concurrency:
1212
group: ${{ github.workflow }}-${{ github.ref }}
1313
cancel-in-progress: true
1414

15+
env:
16+
PHPCS_DEV: 'dev-master'
17+
UTILS_DEV: 'dev-develop'
18+
EXTRA_DEV: 'dev-develop'
19+
1520
jobs:
1621
# Check code style of sniffs, rulesets and XML documentation.
1722
# Check that all sniffs are feature complete.
@@ -24,7 +29,7 @@ jobs:
2429

2530
steps:
2631
- name: Checkout repository
27-
uses: actions/checkout@v3
32+
uses: actions/checkout@v4
2833

2934
- name: Setup PHP
3035
uses: shivammathur/setup-php@v2
@@ -37,12 +42,16 @@ jobs:
3742
- name: Validate the composer.json file
3843
run: composer validate --no-check-all --strict
3944

40-
# Using PHPCS `master` as an early detection system for bugs upstream.
41-
- name: Set PHPCS version
42-
run: composer require squizlabs/php_codesniffer:"dev-master" --no-update --no-scripts --no-interaction
45+
# Using dev versions of the dependencies as an early detection system for bugs upstream.
46+
- name: "Composer: set PHPCS dependencies (dev)"
47+
run: >
48+
composer require --no-update --no-scripts --no-interaction
49+
squizlabs/php_codesniffer:"${{ env.PHPCS_DEV }}"
50+
phpcsstandards/phpcsutils:"${{ env.UTILS_DEV }}"
51+
phpcsstandards/phpcsextra:"${{ env.EXTRA_DEV }}"
4352
4453
- name: Install Composer dependencies
45-
uses: ramsey/composer-install@v2
54+
uses: ramsey/composer-install@v3
4655
with:
4756
# Bust the cache at least once a month - output format: YYYY-MM.
4857
custom-cache-suffix: $(date -u "+%Y-%m")
@@ -54,7 +63,8 @@ jobs:
5463
5564
# Show XML violations inline in the file diff.
5665
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
57-
- uses: korelstar/xmllint-problem-matcher@v1
66+
- name: Enable showing XML issues inline
67+
uses: korelstar/xmllint-problem-matcher@v1
5868

5969
- name: Check the code style of the PHP files
6070
id: phpcs
@@ -92,19 +102,19 @@ jobs:
92102

93103
# Makes sure the rulesets don't throw unexpected errors or warnings.
94104
# This workflow needs to be run against a high PHP version to prevent triggering the syntax error check.
95-
# It also needs to be run against all PHPCS versions WPCS is tested against.
105+
# It also needs to be run against all dependency versions WPCS is tested against.
96106
ruleset-tests:
97107
runs-on: ubuntu-latest
98108
strategy:
99109
matrix:
100110
php: [ 'latest' ]
101-
phpcs_version: [ 'lowest', 'dev-master' ]
111+
dependencies: [ 'lowest', 'stable', 'dev' ]
102112

103-
name: "Ruleset test: PHP ${{ matrix.php }} on PHPCS ${{ matrix.phpcs_version }}"
113+
name: "Ruleset test: PHP ${{ matrix.php }} on PHPCS ${{ matrix.dependencies }}"
104114

105115
steps:
106116
- name: Checkout repository
107-
uses: actions/checkout@v3
117+
uses: actions/checkout@v4
108118

109119
- name: Set up PHP
110120
uses: shivammathur/setup-php@v2
@@ -114,20 +124,28 @@ jobs:
114124
ini-values: error_reporting = E_ALL & ~E_DEPRECATED
115125
coverage: none
116126

117-
- name: "Set PHPCS version (master)"
118-
if: ${{ matrix.phpcs_version != 'lowest' }}
119-
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
127+
- name: "Composer: set PHPCS dependencies for tests (dev)"
128+
if: ${{ matrix.dependencies == 'dev' }}
129+
run: >
130+
composer require --no-update --no-scripts --no-interaction
131+
squizlabs/php_codesniffer:"${{ env.PHPCS_DEV }}"
132+
phpcsstandards/phpcsutils:"${{ env.UTILS_DEV }}"
133+
phpcsstandards/phpcsextra:"${{ env.EXTRA_DEV }}"
120134
121135
- name: Install Composer dependencies
122-
uses: ramsey/composer-install@v2
136+
uses: ramsey/composer-install@v3
123137
with:
124138
composer-options: --no-dev
125139
# Bust the cache at least once a month - output format: YYYY-MM.
126140
custom-cache-suffix: $(date -u "+%Y-%m")
127141

128-
- name: "Set PHPCS version (lowest)"
129-
if: ${{ matrix.phpcs_version == 'lowest' }}
130-
run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction
142+
- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
143+
if: ${{ matrix.dependencies == 'lowest' }}
144+
run: >
145+
composer update --prefer-lowest --no-scripts --no-interaction
146+
squizlabs/php_codesniffer
147+
phpcsstandards/phpcsutils
148+
phpcsstandards/phpcsextra
131149
132150
- name: Test the WordPress-Core ruleset
133151
run: $(pwd)/vendor/bin/phpcs -ps ./Tests/RulesetCheck/class-ruleset-test.inc --standard=WordPress-Core
@@ -150,15 +168,14 @@ jobs:
150168
# Test for fixer conflicts by running the auto-fixers of the complete WPCS over the test case files.
151169
# This is not an exhaustive test, but should give an early indication for typical fixer conflicts.
152170
# If only fixable errors are found, the exit code will be 1, which can be interpreted as success.
153-
#
154-
# Note: the ValidVariableNameUnitTest.inc file is temporarily ignored until upstream PHPCS PR 3833 has been merged.
171+
# This check is only run against "dev" as conflicts can not be fixed for already released versions.
155172
- name: Test for fixer conflicts (fixes expected)
156-
if: ${{ matrix.phpcs_version == 'dev-master' }}
173+
if: ${{ matrix.dependencies == 'dev' }}
157174
id: phpcbf
158175
continue-on-error: true
159176
run: |
160177
set +e
161-
$(pwd)/vendor/bin/phpcbf -pq ./WordPress/Tests/ --standard=WordPress --extensions=inc --exclude=Generic.PHP.Syntax --report=summary --ignore=/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.inc,/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.7.inc
178+
$(pwd)/vendor/bin/phpcbf -pq ./WordPress/Tests/ --standard=WordPress --extensions=inc --exclude=Generic.PHP.Syntax --report=summary --ignore=/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.7.inc
162179
exitcode="$?"
163180
echo "EXITCODE=$exitcode" >> $GITHUB_OUTPUT
164181
exit "$exitcode"
@@ -174,20 +191,20 @@ jobs:
174191

175192
steps:
176193
- name: Checkout code
177-
uses: actions/checkout@v3
194+
uses: actions/checkout@v4
178195

179196
- name: Install PHP
180197
uses: shivammathur/setup-php@v2
181198
with:
182-
php-version: '7.4'
199+
php-version: 'latest'
183200
coverage: none
184201
tools: phpstan
185202

186203
# Install dependencies and handle caching in one go.
187204
# Dependencies need to be installed to make sure the PHPCS and PHPUnit classes are recognized.
188-
# @link https://github.com/marketplace/actions/install-composer-dependencies
205+
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
189206
- name: Install Composer dependencies
190-
uses: "ramsey/composer-install@v2"
207+
uses: "ramsey/composer-install@v3"
191208
with:
192209
# Bust the cache at least once a month - output format: YYYY-MM.
193210
custom-cache-suffix: $(date -u "+%Y-%m")

.github/workflows/manage-labels.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: Clean up labels on PR merge
1818

1919
steps:
20-
- uses: mondeja/remove-labels-gh-action@v1
20+
- uses: mondeja/remove-labels-gh-action@v2
2121
with:
2222
token: ${{ secrets.GITHUB_TOKEN }}
2323
labels: |
@@ -31,7 +31,7 @@ jobs:
3131
name: Clean up labels on PR close
3232

3333
steps:
34-
- uses: mondeja/remove-labels-gh-action@v1
34+
- uses: mondeja/remove-labels-gh-action@v2
3535
with:
3636
token: ${{ secrets.GITHUB_TOKEN }}
3737
labels: |
@@ -46,7 +46,7 @@ jobs:
4646
name: Clean up labels on issue close
4747

4848
steps:
49-
- uses: mondeja/remove-labels-gh-action@v1
49+
- uses: mondeja/remove-labels-gh-action@v2
5050
with:
5151
token: ${{ secrets.GITHUB_TOKEN }}
5252
labels: |

.github/workflows/quicktest.yml

Lines changed: 23 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,74 +23,52 @@ jobs:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
php: [ '5.4', '7.4', 'latest' ]
27-
phpcs_version: [ 'lowest', 'dev-master' ]
26+
php: [ '5.4', 'latest' ]
27+
dependencies: [ 'lowest', 'stable' ]
2828

29-
name: QTest - PHP ${{ matrix.php }} on PHPCS ${{ matrix.phpcs_version }}
29+
name: QTest - PHP ${{ matrix.php }} on PHPCS ${{ matrix.dependencies }}
3030

3131
steps:
3232
- name: Checkout repository
33-
uses: actions/checkout@v3
34-
35-
# On stable PHPCS versions, allow for PHP deprecation notices.
36-
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
37-
- name: Setup ini config
38-
id: set_ini
39-
run: |
40-
if [ "${{ matrix.phpcs_version }}" != "dev-master" ]; then
41-
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> $GITHUB_OUTPUT
42-
else
43-
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
44-
fi
33+
uses: actions/checkout@v4
4534

4635
- name: Set up PHP
4736
uses: shivammathur/setup-php@v2
4837
with:
4938
php-version: ${{ matrix.php }}
50-
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
39+
# With stable PHPCS dependencies, allow for PHP deprecation notices.
40+
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
41+
ini-values: error_reporting=-1, display_errors=On
5142
coverage: ${{ github.ref_name == 'develop' && 'xdebug' || 'none' }}
5243

53-
- name: "Set PHPCS version (master)"
54-
if: ${{ matrix.phpcs_version != 'lowest' }}
55-
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
56-
57-
- name: Install Composer dependencies (PHP < 8.0 )
58-
if: ${{ matrix.php < 8.0 && matrix.php != 'latest' }}
59-
uses: ramsey/composer-install@v2
44+
- name: Install Composer dependencies
45+
uses: ramsey/composer-install@v3
6046
with:
6147
# Bust the cache at least once a month - output format: YYYY-MM.
6248
custom-cache-suffix: $(date -u "+%Y-%m")
6349

64-
- name: Install Composer dependencies (PHP >= 8.0)
65-
if: ${{ matrix.php >= 8.0 || matrix.php == 'latest' }}
66-
uses: ramsey/composer-install@v2
67-
with:
68-
composer-options: --ignore-platform-req=php+
69-
custom-cache-suffix: $(date -u "+%Y-%m")
70-
71-
- name: "Set PHPCS version (lowest)"
72-
if: ${{ matrix.phpcs_version == 'lowest' }}
73-
run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction
50+
- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
51+
if: ${{ matrix.dependencies == 'lowest' }}
52+
run: >
53+
composer update --prefer-lowest --no-scripts --no-interaction
54+
squizlabs/php_codesniffer
55+
phpcsstandards/phpcsutils
56+
phpcsstandards/phpcsextra
7457
7558
- name: Lint PHP files against parse errors
76-
if: ${{ matrix.phpcs_version == 'dev-master' }}
77-
run: composer lint -- --checkstyle
59+
if: ${{ matrix.dependencies == 'stable' }}
60+
run: composer lint
7861

79-
- name: Run the unit tests without code coverage - PHP 5.4 - 8.0
80-
if: ${{ matrix.php == '5.4' && github.ref_name != 'develop' }}
62+
- name: Run the unit tests without code coverage
63+
if: ${{ github.ref_name != 'develop' }}
8164
run: composer run-tests
8265

83-
# Until PHPCS supports PHPUnit 9, we cannot run code coverage on PHP 8.0+, so run it on PHP 5.4 and 7.4.
84-
- name: Run the unit tests with code coverage - PHP 5.4 - 8.0
85-
if: ${{ matrix.php != 'latest' && github.ref_name == 'develop' }}
66+
- name: Run the unit tests with code coverage
67+
if: ${{ github.ref_name == 'develop' }}
8668
run: composer coverage
8769

88-
- name: Run the unit tests without code coverage - PHP >= 8.1
89-
if: ${{ matrix.php == 'latest' }}
90-
run: composer run-tests -- --no-configuration --bootstrap=./Tests/bootstrap.php --dont-report-useless-tests
91-
9270
- name: Send coverage report to Codecov
93-
if: ${{ success() && github.ref_name == 'develop' && matrix.php != 'latest' }}
71+
if: ${{ success() && github.ref_name == 'develop' }}
9472
uses: codecov/codecov-action@v3
9573
with:
9674
files: ./build/logs/clover.xml

0 commit comments

Comments
 (0)