Skip to content

Commit 2b1d206

Browse files
authored
Merge pull request #822 from Automattic/develop
Release: 3.0.1
2 parents 1b8960e + 9e91528 commit 2b1d206

27 files changed

+189
-163
lines changed

.github/CONTRIBUTING.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,42 @@ To determine where best to report the bug, use the first part of the sniff name:
1919

2020
Sniff name starts with | Report to
2121
--- | ---
22-
`Generic` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
23-
`PSR2` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
24-
`Squiz` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
22+
`Generic` | [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/)
23+
`PSR2` | [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/)
24+
`Squiz` | [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/)
2525
`Universal` | [PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/issues/)
2626
`VariableAnalysis` | [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis/issues/)
2727
`WordPress` | [WordPressCS](https://github.com/WordPress/WordPress-Coding-Standards/issues/)
2828
`WordPressVIPMinimum` | [VIPCS](https://github.com/Automattic/VIP-Coding-Standards/issues/) (this repo)
2929

3030
----
3131

32+
## Getting the source files
33+
34+
```sh
35+
git clone git@github.com:Automattic/VIP-Coding-Standards.git vipcs
36+
```
37+
38+
...or:
39+
40+
```sh
41+
gh repo clone Automattic/VIP-Coding-Standards vipcs
42+
```
43+
44+
Now `cd vipcs` and run:
45+
46+
```sh
47+
composer install
48+
```
49+
50+
You can now run:
51+
52+
```
53+
composer check
54+
```
55+
56+
... and all checks should pass.
57+
3258
## tl;dr Composer Scripts
3359

3460
This package contains Composer scripts to quickly run the developer checks which are described (with setups) further below.
@@ -67,7 +93,7 @@ When you introduce new `public` sniff properties, or your sniff extends a class
6793
* WordPress-Coding-Standards
6894
* PHPCSUtils 1.x
6995
* PHP_CodeSniffer 3.x
70-
* PHPUnit 4.x, 5.x, 6.x or 7.x
96+
* PHPUnit 4.x - 9.x
7197

7298
The VIP Coding Standards use the PHP_CodeSniffer native unit test suite for unit testing the sniffs.
7399

@@ -78,7 +104,7 @@ N.B.: If you installed VIPCS using Composer, make sure you used `--prefer-source
78104
If you already have PHPUnit installed on your system: Congrats, you're all set.
79105

80106
If not, you can navigate to the directory where the `PHP_CodeSniffer` repo is checked out and do `composer install` to install the `dev` dependencies.
81-
Alternatively, you can [install PHPUnit](https://phpunit.readthedocs.io/en/7.5/installation.html) as a PHAR file.
107+
Alternatively, you can [install PHPUnit](https://phpunit.readthedocs.io/en/9.6/installation.html) as a PHAR file.
82108

83109
### Before running the unit tests
84110

@@ -118,7 +144,7 @@ The easiest way to do this is to add a `phpunit.xml` file to the root of your VI
118144

119145
Expected output:
120146
```
121-
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
147+
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.
122148

123149
........................................ 40 / 40 (100%)
124150

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Use `php -v` and `composer show` to get versions.
4747
| PHPCSUtils version | x.y.z
4848
| VIPCS version | x.y.z
4949
| WordPressCS version | x.y.z
50+
| PHPCSExtra version | x.y.z
5051
| VariableAnalysis version | x.y.z
5152

5253
## Additional Context (optional)

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
commit-message:
14+
prefix: "GH Actions:"
15+
labels:
16+
- "Type: Maintenance"

.github/workflows/basics.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
steps:
2626
- name: Checkout code
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2828

2929
- name: Install PHP
3030
uses: shivammathur/setup-php@v2
@@ -33,14 +33,20 @@ jobs:
3333
coverage: none
3434
tools: cs2pr
3535

36+
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
37+
# This should not be blocking for this job, so ignore any errors from this step.
38+
# Ref: https://github.com/dotnet/core/issues/4167
39+
- name: Update the available packages list
40+
continue-on-error: true
41+
run: sudo apt-get update
42+
3643
- name: Install xmllint
37-
run: |
38-
sudo apt-get update
39-
sudo apt-get install --no-install-recommends -y libxml2-utils
44+
run: sudo apt-get install --no-install-recommends -y libxml2-utils
4045

4146
# Show XML violations inline in the file diff.
4247
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
43-
- uses: korelstar/xmllint-problem-matcher@v1
48+
- name: Enable showing XML issues inline
49+
uses: korelstar/xmllint-problem-matcher@v1
4450

4551
# Validate the composer.json file.
4652
# @link https://getcomposer.org/doc/03-cli.md#validate
@@ -52,9 +58,9 @@ jobs:
5258
run: composer require --no-update --no-scripts squizlabs/php_codesniffer:"dev-master" --no-interaction
5359

5460
# Install dependencies and handle caching in one go.
55-
# @link https://github.com/marketplace/actions/install-composer-dependencies
61+
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
5662
- name: Install Composer dependencies
57-
uses: "ramsey/composer-install@v2"
63+
uses: "ramsey/composer-install@v3"
5864
with:
5965
# Bust the cache at least once a month - output format: YYYY-MM.
6066
custom-cache-suffix: $(date -u "+%Y-%m")
@@ -84,20 +90,20 @@ jobs:
8490

8591
steps:
8692
- name: Checkout code
87-
uses: actions/checkout@v3
93+
uses: actions/checkout@v4
8894

8995
- name: Install PHP
9096
uses: shivammathur/setup-php@v2
9197
with:
92-
php-version: '7.4'
98+
php-version: 'latest'
9399
coverage: none
94100
tools: phpstan
95101

96102
# Install dependencies and handle caching in one go.
97103
# Dependencies need to be installed to make sure the PHPCS and PHPUnit classes are recognized.
98-
# @link https://github.com/marketplace/actions/install-composer-dependencies
104+
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
99105
- name: Install Composer dependencies
100-
uses: "ramsey/composer-install@v2"
106+
uses: "ramsey/composer-install@v3"
101107
with:
102108
# Bust the cache at least once a month - output format: YYYY-MM.
103109
custom-cache-suffix: $(date -u "+%Y-%m")

.github/workflows/quicktest.yml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040

4141
steps:
4242
- name: Checkout code
43-
uses: actions/checkout@v3
43+
uses: actions/checkout@v4
4444

4545
- name: Set up PHP
4646
uses: shivammathur/setup-php@v2
@@ -52,25 +52,15 @@ jobs:
5252
coverage: none
5353

5454
# Install dependencies and handle caching in one go.
55-
# @link https://github.com/marketplace/actions/install-composer-dependencies
56-
- name: Install Composer dependencies - normal
57-
if: ${{ startsWith( matrix.php, '8' ) == false && matrix.php != 'latest' }}
58-
uses: "ramsey/composer-install@v2"
55+
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
56+
- name: Install Composer dependencies
57+
uses: "ramsey/composer-install@v3"
5958
with:
6059
# Bust the cache at least once a month - output format: YYYY-MM.
6160
custom-cache-suffix: $(date -u "+%Y-%m")
6261

63-
# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
64-
# requirements to get PHPUnit 7.x to install on nightly.
65-
- name: Install Composer dependencies - with ignore platform
66-
if: ${{ startsWith( matrix.php, '8' ) || matrix.php == 'latest' }}
67-
uses: "ramsey/composer-install@v2"
68-
with:
69-
composer-options: --ignore-platform-req=php+
70-
custom-cache-suffix: $(date -u "+%Y-%m")
71-
7262
- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
73-
if: ${{ matrix.php == '5.4' && matrix.dependencies == 'lowest' }}
63+
if: ${{ matrix.dependencies == 'lowest' }}
7464
run: >
7565
composer update --prefer-lowest --no-scripts --no-interaction
7666
squizlabs/php_codesniffer
@@ -79,16 +69,6 @@ jobs:
7969
sirbrillig/phpcs-variable-analysis
8070
wp-coding-standards/wpcs
8171
82-
- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
83-
if: ${{ matrix.php == 'latest' && matrix.dependencies == 'lowest' }}
84-
run: >
85-
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
86-
squizlabs/php_codesniffer
87-
phpcsstandards/phpcsutils
88-
phpcsstandards/phpcsextra
89-
sirbrillig/phpcs-variable-analysis
90-
wp-coding-standards/wpcs
91-
9272
- name: Display PHPCS installed standards
9373
run: ./vendor/bin/phpcs -i
9474

.github/workflows/test.yml

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ jobs:
2828

2929
strategy:
3030
matrix:
31-
php: ['5.4', 'latest', '8.3']
31+
php: ['5.4', 'latest', '8.4']
3232

3333
name: "Lint: PHP ${{ matrix.php }}"
34-
continue-on-error: ${{ matrix.php == '8.3' }}
34+
continue-on-error: ${{ matrix.php == '8.4' }}
3535

3636
steps:
3737
- name: Checkout code
38-
uses: actions/checkout@v3
38+
uses: actions/checkout@v4
3939

4040
- name: Install PHP
4141
uses: shivammathur/setup-php@v2
@@ -45,7 +45,7 @@ jobs:
4545
tools: cs2pr
4646

4747
- name: Install Composer dependencies
48-
uses: "ramsey/composer-install@v2"
48+
uses: "ramsey/composer-install@v3"
4949
with:
5050
# Bust the cache at least once a month - output format: YYYY-MM.
5151
custom-cache-suffix: $(date -u "+%Y-%m")
@@ -67,8 +67,9 @@ jobs:
6767
# - PHPCS will run without errors on PHP 5.4 - 7.4 on any supported version.
6868
# - PHP 8.0 needs PHPCS 3.5.7+ to run without errors, and we require a higher minimum version.
6969
# - 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.
70+
# - PHP 8.2 and 8.3 need PHPCS 3.8.0+ to run without errors (though the errors don't affect the tests).
7071
matrix:
71-
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
72+
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
7273
dependencies: ['lowest', 'stable']
7374

7475
include:
@@ -79,20 +80,20 @@ jobs:
7980
dependencies: 'dev'
8081
- php: '7.4'
8182
dependencies: 'dev'
82-
- php: '8.2'
83+
- php: '8.3'
8384
dependencies: 'dev'
8485

8586
# Test against upcoming PHP version.
86-
- php: '8.3'
87+
- php: '8.4'
8788
dependencies: 'dev'
8889

8990
name: "Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.dependencies }}"
9091

91-
continue-on-error: ${{ matrix.php == '8.3' }}
92+
continue-on-error: ${{ matrix.php == '8.4' }}
9293

9394
steps:
9495
- name: Checkout code
95-
uses: actions/checkout@v3
96+
uses: actions/checkout@v4
9697

9798
# With stable PHPCS dependencies, allow for PHP deprecation notices.
9899
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
@@ -123,25 +124,15 @@ jobs:
123124
wp-coding-standards/wpcs:"dev-develop"
124125
125126
# Install dependencies and handle caching in one go.
126-
# @link https://github.com/marketplace/actions/install-composer-dependencies
127-
- name: Install Composer dependencies - normal
128-
if: ${{ startsWith( matrix.php, '8' ) == false }}
129-
uses: "ramsey/composer-install@v2"
127+
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
128+
- name: Install Composer dependencies
129+
uses: "ramsey/composer-install@v3"
130130
with:
131131
# Bust the cache at least once a month - output format: YYYY-MM.
132132
custom-cache-suffix: $(date -u "+%Y-%m")
133133

134-
# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
135-
# requirements to get PHPUnit 7.x to install on nightly.
136-
- name: Install Composer dependencies - with ignore platform
137-
if: ${{ startsWith( matrix.php, '8' ) }}
138-
uses: "ramsey/composer-install@v2"
139-
with:
140-
composer-options: --ignore-platform-req=php+
141-
custom-cache-suffix: $(date -u "+%Y-%m")
142-
143134
- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
144-
if: ${{ ! startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
135+
if: ${{ matrix.dependencies == 'lowest' }}
145136
run: >
146137
composer update --prefer-lowest --no-scripts --no-interaction
147138
squizlabs/php_codesniffer
@@ -150,16 +141,6 @@ jobs:
150141
sirbrillig/phpcs-variable-analysis
151142
wp-coding-standards/wpcs
152143
153-
- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
154-
if: ${{ startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
155-
run: >
156-
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
157-
squizlabs/php_codesniffer
158-
phpcsstandards/phpcsutils
159-
phpcsstandards/phpcsextra
160-
sirbrillig/phpcs-variable-analysis
161-
wp-coding-standards/wpcs
162-
163144
- name: Run the unit tests
164145
run: ./bin/unit-tests
165146

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ phpcs.xml
66
phpunit.xml
77
phpcs.cache
88
phpstan.neon
9+
.phpunit.result.cache

.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="VIP Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="VIP Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
33
<description>The custom ruleset for the VIP Coding Standards itself.</description>
44

55
<file>.</file>

0 commit comments

Comments
 (0)