Skip to content

Commit b8610e3

Browse files
authored
Merge pull request #772 from Automattic/release/2.3.4
2 parents 6cd0a6a + ef8d4b3 commit b8610e3

File tree

107 files changed

+550
-463
lines changed

Some content is hidden

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

107 files changed

+550
-463
lines changed

.gitattributes

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
# If you develop for VIPCS using Composer, use `--prefer-source`.
55
# https://blog.madewithlove.be/post/gitattributes/
66
#
7-
/.editorconfig export-ignore
8-
/.gitattributes export-ignore
9-
/.gitignore export-ignore
10-
/.phpcs.xml.dist export-ignore
11-
/phpunit.xml.dist export-ignore
12-
/.github export-ignore
13-
/bin export-ignore
14-
/tests export-ignore
7+
/.editorconfig export-ignore
8+
/.gitattributes export-ignore
9+
/.gitignore export-ignore
10+
/.phpcs.xml.dist export-ignore
11+
/phpunit.xml.dist export-ignore
12+
/.github export-ignore
13+
/bin export-ignore
14+
/tests export-ignore
1515
/WordPressVIPMinimum/Tests export-ignore
1616

1717
#

.github/CONTRIBUTING.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ This package contains Composer scripts to quickly run the developer checks which
3434

3535
After `composer install`, you can do:
3636

37-
- `composer test`: **Run all checks and tests** - this should pass cleanly before you submit a pull request.
38-
- `composer lint`: Just run PHP and XML linters.
39-
- `composer phpcs`: Just run PHPCS against this package.
40-
- `composer phpunit`: Just run the unit tests.
41-
- `composer ruleset`: Just run the ruleset tests.
37+
- `composer lint`: Lint PHP and XML files in against parse errors.
38+
- `composer cs`: Check the code style and code quality of the codebase via PHPCS.
39+
- `composer test`: Run the unit tests for the VIPCS sniffs.
40+
- `composer test-coverage`: Run the unit tests for the VIPCS sniffs with coverage enabled.
41+
- `composer test-ruleset`: Run the ruleset tests for the VIPCS sniffs.
42+
- `composer feature-completeness`: Check if all the VIPCS sniffs have tests.
43+
- `composer check`: Run all checks (lint, CS, feature completeness) and tests - this should pass cleanly before you submit a pull request.
4244

4345
## Branches
4446

@@ -190,7 +192,7 @@ The ruleset tests, previously named here as _integration tests_, are our way of
190192

191193
An example where it might not would be when a ruleset references a local sniff or a sniff from upstream (WPCS or PHPCS), but that the violation code, sniff name or category name has changed. Without a ruleset test, this would go unnoticed.
192194

193-
The `composer test` or `composer ruleset` commands run the `ruleset-test.php` files (one for each standard), which internally run `phpcs` against the "dirty" test files (`ruleset-test.inc`), and looks out for a known number of errors, warnings, and messages on each line. This is then compared against the expected errors, warnings and messages to see if there are any missing or unexpected violations or difference in messages.
195+
The `composer check` or `composer test-ruleset` commands run the `ruleset-test.php` files (one for each standard), which internally run `phpcs` against the "dirty" test files (`ruleset-test.inc`), and looks out for a known number of errors, warnings, and messages on each line. This is then compared against the expected errors, warnings and messages to see if there are any missing or unexpected violations or difference in messages.
194196

195197
When adding or changing a sniff, the ruleset test files should be updated to match.
196198

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ e.g. `WordPressVIPMinimum.PHP.NoSilencedErrors.Discouraged`
4040

4141
Use `php -v` and `composer show` to get versions.
4242

43-
| Question | Answer
44-
| ------------------------| -------
45-
| PHP version | x.y.z
46-
| PHP_CodeSniffer version | x.y.z
47-
| VIPCS version | x.y.z
43+
| Question | Answer
44+
| ------------------------ | -------
45+
| PHP version | x.y.z
46+
| PHP_CodeSniffer version | x.y.z
47+
| VIPCS version | x.y.z
48+
| WordPressCS version | x.y.z
49+
| VariableAnalysis version | x.y.z
4850

4951
## Additional Context (optional)
5052

.github/workflows/basics.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@ on:
77
paths-ignore:
88
- '**.md'
99
pull_request:
10+
1011
# Allow manually triggering the workflow.
1112
workflow_dispatch:
1213

14+
# Cancels all previous workflow runs for the same branch that have not yet completed.
15+
concurrency:
16+
# The concurrency group contains the workflow name and the branch name.
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
1320
jobs:
1421
checkcs:
1522
name: 'Basic CS and QA checks'
1623
runs-on: ubuntu-latest
1724

1825
steps:
1926
- name: Checkout code
20-
uses: actions/checkout@v2
27+
uses: actions/checkout@v3
2128

2229
- name: Install PHP
2330
uses: shivammathur/setup-php@v2
@@ -27,7 +34,9 @@ jobs:
2734
tools: cs2pr
2835

2936
- name: Install xmllint
30-
run: sudo apt-get install --no-install-recommends -y libxml2-utils
37+
run: |
38+
sudo apt-get update
39+
sudo apt-get install --no-install-recommends -y libxml2-utils
3140
3241
# Show XML violations inline in the file diff.
3342
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
@@ -40,26 +49,30 @@ jobs:
4049

4150
- name: 'Composer: adjust dependencies'
4251
# Using PHPCS `master` as an early detection system for bugs upstream.
43-
run: composer require --no-update --no-scripts squizlabs/php_codesniffer:"dev-master"
52+
run: composer require --no-update --no-scripts squizlabs/php_codesniffer:"dev-master" --no-interaction
4453

4554
# Install dependencies and handle caching in one go.
4655
# @link https://github.com/marketplace/actions/install-composer-dependencies
4756
- name: Install Composer dependencies
48-
uses: "ramsey/composer-install@v1"
57+
uses: "ramsey/composer-install@v2"
58+
with:
59+
# Bust the cache at least once a month - output format: YYYY-MM.
60+
custom-cache-suffix: $(date -u "+%Y-%m")
4961

5062
- name: 'Validate XML against schema and check code style'
5163
run: ./bin/xml-lint
5264

5365
# Check the code-style consistency of the PHP files.
5466
- name: Check PHP code style
55-
continue-on-error: true
67+
id: phpcs
5668
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml
5769

5870
- name: Show PHPCS results in PR
71+
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
5972
run: cs2pr ./phpcs-report.xml
6073

6174
# Check that the sniffs available are feature complete.
6275
# For now, just check that all sniffs have unit tests.
6376
# At a later stage the documentation check can be activated.
6477
- name: Check sniff feature completeness
65-
run: composer check-complete
78+
run: composer feature-completeness

.github/workflows/quicktest.yml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ on:
1010
# Allow manually triggering the workflow.
1111
workflow_dispatch:
1212

13+
# Cancels all previous workflow runs for the same branch that have not yet completed.
14+
concurrency:
15+
# The concurrency group contains the workflow name and the branch name.
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
1319
jobs:
1420
#### QUICK TEST STAGE ####
1521
# This is a much quicker test which only runs the unit tests and linting against the low/high
@@ -24,60 +30,67 @@ jobs:
2430
phpcs_version: 'dev-master'
2531
wpcs_version: '2.3.*'
2632
- php: '5.4'
27-
phpcs_version: '3.5.5'
33+
phpcs_version: '3.7.1'
2834
wpcs_version: '2.3.*'
2935

3036
- php: 'latest'
3137
phpcs_version: 'dev-master'
3238
wpcs_version: '2.3.*'
3339
- php: 'latest'
34-
# PHPCS 3.5.7 is the lowest version of PHPCS which supports PHP 8.0.
35-
phpcs_version: '3.5.7'
40+
phpcs_version: '3.7.1'
3641
wpcs_version: '2.3.*'
3742

3843
name: "QTest${{ matrix.phpcs_version == 'dev-master' && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
3944

40-
4145
steps:
4246
- name: Checkout code
43-
uses: actions/checkout@v2
47+
uses: actions/checkout@v3
4448

4549
# On stable PHPCS versions, allow for PHP deprecation notices.
4650
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
51+
# Note: the "elif" condition is temporary and should be removed once VIPCS updates to WPCS 3.0+.
4752
- name: Setup ini config
4853
id: set_ini
4954
run: |
5055
if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then
51-
echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED'
56+
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> $GITHUB_OUTPUT
5257
else
53-
echo '::set-output name=PHP_INI::error_reporting=E_ALL'
58+
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
5459
fi
5560
56-
- name: Install PHP
61+
- name: Set up PHP
5762
uses: shivammathur/setup-php@v2
5863
with:
5964
php-version: ${{ matrix.php }}
6065
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
6166
coverage: none
6267

63-
- name: 'Composer: set PHPCS and WPCS versions for tests'
64-
run: |
65-
composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}"
66-
composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}"
68+
- name: 'Composer: set PHPCS version for tests'
69+
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
70+
71+
- name: 'Composer: set WPCS version for tests'
72+
run: composer require wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-update --no-scripts --no-interaction
6773

6874
# Install dependencies and handle caching in one go.
6975
# @link https://github.com/marketplace/actions/install-composer-dependencies
7076
- name: Install Composer dependencies - normal
7177
if: ${{ startsWith( matrix.php, '8' ) == false && matrix.php != 'latest' }}
72-
uses: "ramsey/composer-install@v1"
78+
uses: "ramsey/composer-install@v2"
79+
with:
80+
# Bust the cache at least once a month - output format: YYYY-MM.
81+
custom-cache-suffix: $(date -u "+%Y-%m")
7382

7483
# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
7584
# requirements to get PHPUnit 7.x to install on nightly.
7685
- name: Install Composer dependencies - with ignore platform
7786
if: ${{ startsWith( matrix.php, '8' ) || matrix.php == 'latest' }}
78-
uses: "ramsey/composer-install@v1"
87+
uses: "ramsey/composer-install@v2"
7988
with:
8089
composer-options: --ignore-platform-reqs
90+
custom-cache-suffix: $(date -u "+%Y-%m")
91+
92+
- name: Display PHPCS installed standards
93+
run: ./vendor/bin/phpcs -i
8194

8295
- name: Lint against parse errors
8396
if: matrix.phpcs_version == 'dev-master'

.github/workflows/test.yml

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@ on:
99
paths-ignore:
1010
- '**.md'
1111
pull_request:
12+
1213
# Allow manually triggering the workflow.
1314
workflow_dispatch:
1415

16+
# Cancels all previous workflow runs for the same branch that have not yet completed.
17+
concurrency:
18+
# The concurrency group contains the workflow name and the branch name.
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
1522
jobs:
1623
#### PHP LINT STAGE ####
1724
# Linting against high/low PHP versions should catch everything.
@@ -21,19 +28,14 @@ jobs:
2128

2229
strategy:
2330
matrix:
24-
php: ['5.4', 'latest']
25-
experimental: [false]
26-
27-
include:
28-
- php: '8.1'
29-
experimental: true
31+
php: ['5.4', 'latest', '8.3']
3032

3133
name: "Lint: PHP ${{ matrix.php }}"
32-
continue-on-error: ${{ matrix.experimental }}
34+
continue-on-error: ${{ matrix.php == '8.3' }}
3335

3436
steps:
3537
- name: Checkout code
36-
uses: actions/checkout@v2
38+
uses: actions/checkout@v3
3739

3840
- name: Install PHP
3941
uses: shivammathur/setup-php@v2
@@ -43,7 +45,10 @@ jobs:
4345
tools: cs2pr
4446

4547
- name: Install Composer dependencies
46-
uses: "ramsey/composer-install@v1"
48+
uses: "ramsey/composer-install@v2"
49+
with:
50+
# Bust the cache at least once a month - output format: YYYY-MM.
51+
custom-cache-suffix: $(date -u "+%Y-%m")
4752

4853
- name: Lint against parse errors
4954
run: ./bin/php-lint --checkstyle | cs2pr
@@ -60,52 +65,41 @@ jobs:
6065
# - phpcs_version: The PHPCS versions to test against.
6166
# IMPORTANT: test runs shouldn't fail because of PHPCS being incompatible with a PHP version.
6267
# - PHPCS will run without errors on PHP 5.4 - 7.4 on any supported version.
63-
# - PHP 8.0 needs PHPCS 3.5.7+ to run without errors.
68+
# - PHP 8.0 needs PHPCS 3.5.7+ to run without errors, and we require a higher minimum version.
69+
# - PHP 8.1 needs PHPCS 3.6.1+ to run without errors, but works best with 3.7.1+, and we require at least this minimum version.
6470
# - The `wpcs_version` key is added to allow additional test builds when multiple WPCS versions
6571
# would be supported. As, at this time, only the latest stable release of WPCS is supported,
6672
# no additional versions are included in the array.
67-
# - experimental: Whether the build is "allowed to fail".
6873
matrix:
69-
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
70-
phpcs_version: ['3.5.5', 'dev-master']
74+
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
75+
phpcs_version: ['3.7.1', 'dev-master']
7176
wpcs_version: ['2.3.*']
72-
experimental: [false]
7377

7478
include:
75-
# Complete the matrix by adding PHP 8.0, but only test against compatible PHPCS versions.
76-
- php: '8.0'
79+
- php: '8.3'
7780
phpcs_version: 'dev-master'
7881
wpcs_version: '2.3.*'
79-
experimental: false
80-
- php: '8.0'
81-
# PHPCS 3.5.7 is the lowest version of PHPCS which supports PHP 8.0.
82-
phpcs_version: '3.5.7'
83-
wpcs_version: '2.3.*'
84-
experimental: false
85-
86-
# Experimental builds. These are allowed to fail.
87-
#- php: '8.1'
88-
# phpcs_version: 'dev-master'
89-
# wpcs_version: '2.3.*'
90-
# experimental: true
9182

9283
name: "Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }} - WPCS ${{ matrix.wpcs_version }}"
9384

94-
continue-on-error: ${{ matrix.experimental }}
85+
continue-on-error: ${{ matrix.php == '8.3' }}
9586

9687
steps:
9788
- name: Checkout code
98-
uses: actions/checkout@v2
89+
uses: actions/checkout@v3
9990

10091
# On stable PHPCS versions, allow for PHP deprecation notices.
10192
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
93+
# Note: the "elif" condition is temporary and should be removed once VIPCS updates to WPCS 3.0+.
10294
- name: Setup ini config
10395
id: set_ini
10496
run: |
10597
if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then
106-
echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED'
98+
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED' >> $GITHUB_OUTPUT
99+
elif [[ "${{ matrix.php }}" == "8.1" ]]; then
100+
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED' >> $GITHUB_OUTPUT
107101
else
108-
echo '::set-output name=PHP_INI::error_reporting=E_ALL'
102+
echo 'PHP_INI=error_reporting=-1' >> $GITHUB_OUTPUT
109103
fi
110104
111105
- name: Install PHP
@@ -115,24 +109,29 @@ jobs:
115109
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
116110
coverage: none
117111

118-
- name: 'Composer: set PHPCS and WPCS versions for tests'
119-
run: |
120-
composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}"
121-
composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}"
112+
- name: 'Composer: set PHPCS version for tests'
113+
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
114+
115+
- name: 'Composer: set WPCS version for tests'
116+
run: composer require wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-update --no-scripts --no-interaction
122117

123118
# Install dependencies and handle caching in one go.
124119
# @link https://github.com/marketplace/actions/install-composer-dependencies
125120
- name: Install Composer dependencies - normal
126121
if: ${{ startsWith( matrix.php, '8' ) == false }}
127-
uses: "ramsey/composer-install@v1"
122+
uses: "ramsey/composer-install@v2"
123+
with:
124+
# Bust the cache at least once a month - output format: YYYY-MM.
125+
custom-cache-suffix: $(date -u "+%Y-%m")
128126

129127
# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
130128
# requirements to get PHPUnit 7.x to install on nightly.
131129
- name: Install Composer dependencies - with ignore platform
132130
if: ${{ startsWith( matrix.php, '8' ) }}
133-
uses: "ramsey/composer-install@v1"
131+
uses: "ramsey/composer-install@v2"
134132
with:
135133
composer-options: --ignore-platform-reqs
134+
custom-cache-suffix: $(date -u "+%Y-%m")
136135

137136
- name: Run the unit tests
138137
run: ./bin/unit-tests

.phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<rule ref="WordPress-Extra">
2020
<exclude name="WordPress.Files.FileName"/>
2121
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
22+
<exclude name="WordPress.NamingConventions.PrefixAllGlobals"/>
2223
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
2324
<exclude name="WordPress.PHP.YodaConditions"/>
2425
</rule>

0 commit comments

Comments
 (0)