Skip to content

Commit 06c1eff

Browse files
authored
Merge pull request #282 from humanmade/update-phpcs
Update PHPCS to support PHP 8+
2 parents 20ace91 + 92a3f64 commit 06c1eff

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ jobs:
3131
- composer install
3232
script:
3333
- vendor/bin/phpunit
34+
- language: php
35+
php: 8.0
36+
install:
37+
# For PHP 8.0+, we need to ignore platform reqs as PHPUnit 7 is still used.
38+
- composer install --ignore-platform-reqs
39+
script:
40+
- vendor/bin/phpunit
41+
- language: php
42+
php: 8.1
43+
install:
44+
# For PHP 8.0+, we need to ignore platform reqs as PHPUnit 7 is still used.
45+
- composer install --ignore-platform-reqs
46+
script:
47+
# For PHP 8.1+, we need to ignore the config file so that PHPUnit 7 doesn't try to read it and cause an error.
48+
# Instead, we pass all required settings as part of the phpunit command.
49+
- vendor/bin/phpunit --no-configuration --bootstrap=tests/bootstrap.php --dont-report-useless-tests tests/AllSniffs.php
50+
- vendor/bin/phpunit --no-configuration --bootstrap=tests/bootstrap.php --dont-report-useless-tests tests/FixtureTests.php
3451
- language: node_js
3552
node_js: 16
3653
install:

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
"license": "GPL-2.0-or-later",
66
"require": {
77
"php": ">=7.1",
8-
"wp-coding-standards/wpcs": "2.2.1",
8+
"wp-coding-standards/wpcs": "2.3.0",
99
"automattic/vipwpcs": "2.0.0",
1010
"fig-r/psr2r-sniffer": "^0.5.0",
1111
"phpcompatibility/phpcompatibility-wp": "^2.0.0",
12-
"squizlabs/php_codesniffer": "~3.5.0",
12+
"squizlabs/php_codesniffer": "~3.5",
1313
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": "^5.7"
16+
"phpunit/phpunit": "^7"
1717
},
1818
"scripts": {
1919
"test": "phpunit"

phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<phpunit
2+
beStrictAboutTestsThatDoNotTestAnything="false"
23
bootstrap="tests/bootstrap.php"
34
colors="true"
45
convertErrorsToExceptions="true"
@@ -7,7 +8,7 @@
78
>
89
<testsuites>
910
<!-- Default test suite to run all tests -->
10-
<testsuite>
11+
<testsuite name="all">
1112
<file>tests/AllSniffs.php</file>
1213
<file>tests/FixtureTests.php</file>
1314
</testsuite>

tests/AllSniffs.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public static function main() {
4242
public static function suite() {
4343
$GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'] = array();
4444
$GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'] = array();
45+
$GLOBALS['PHP_CODESNIFFER_SNIFF_CASE_FILES'] = array();
4546

4647
$suite = new TestSuite( 'HM Standards' );
4748

tests/bootstrap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
// Check phpcs is installed.
88
$phpcs_dir = dirname( __DIR__ ) . '/vendor/squizlabs/php_codesniffer';
9-
if ( ! file_exists($phpcs_dir)) {
10-
throw new Exception( 'Could not find PHP_CodeSniffer. Run `composer install --prefer-source --dev`' );
9+
if ( ! file_exists( $phpcs_dir ) ) {
10+
throw new Exception( 'Could not find PHP_CodeSniffer. Run `composer install --prefer-source`' );
1111
}
1212

1313
// Check phpcs' test framework is available.

0 commit comments

Comments
 (0)