Skip to content

Commit 0ff0080

Browse files
authored
Merge pull request #347 from PHPCSStandards/feature/drop-support-phpcs-lt-371
Drop support for PHPCS < 3.7.1
2 parents 6242122 + 3b413c1 commit 0ff0080

File tree

109 files changed

+1335
-5763
lines changed

Some content is hidden

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

109 files changed

+1335
-5763
lines changed

.github/workflows/basics.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ jobs:
4646
composer remove --no-update --dev phpunit/phpunit --no-scripts
4747
# Using PHPCS `master` as an early detection system for bugs upstream.
4848
composer require --no-update squizlabs/php_codesniffer:"dev-master"
49-
# Add PHPCSDevCS - this is the CS ruleset we use.
50-
# This is not in the composer.json as it has different minimum PHPCS reqs and would conflict.
51-
composer require --no-update --dev phpcsstandards/phpcsdevcs:"^1.1.3"
5249
5350
# Install dependencies and handle caching in one go.
5451
# @link https://github.com/marketplace/actions/install-composer-dependencies

.github/workflows/quicktest.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@ jobs:
2727
quicktest:
2828
runs-on: ubuntu-latest
2929

30+
env:
31+
# - COMPOSER_ROOT_VERSION is needed to get round the recursive dependency when using CI.
32+
COMPOSER_ROOT_VERSION: '1.99.99'
33+
3034
strategy:
3135
matrix:
3236
php: ['5.4', 'latest']
33-
phpcs_version: ['dev-master']
34-
35-
include:
36-
- php: '7.3'
37-
phpcs_version: '2.9.2'
38-
- php: '5.4'
39-
phpcs_version: '2.6.0'
37+
phpcs_version: ['3.7.1', 'dev-master']
4038

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

.github/workflows/test.yml

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ concurrency:
1919
group: ${{ github.workflow }}-${{ github.ref }}
2020
cancel-in-progress: true
2121

22+
env:
23+
# - COMPOSER_ROOT_VERSION is needed to get round the recursive dependency when using CI.
24+
COMPOSER_ROOT_VERSION: '1.99.99'
25+
2226
jobs:
2327
lint:
2428
if: ${{ github.ref != 'refs/heads/develop' }}
@@ -76,53 +80,24 @@ jobs:
7680
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
7781
#
7882
# IMPORTANT: test runs shouldn't fail because of PHPCS being incompatible with a PHP version.
79-
# - PHPCS will run without errors on PHP 5.4 - 7.2 on any version.
80-
# - PHP 7.3 needs PHPCS 2.9.2 and 3.3.1+ to run without notices.
81-
# As deprecations are ignored for older PHPCS versions, our tests still shouldn't fail.
82-
# - PHP 7.4 needs PHPCS 3.5.0+ to run without notices.
83-
# As deprecations are ignored for older PHPCS versions, our tests still shouldn't fail.
84-
# - PHP 8.0 needs PHPCS 3.5.0+ to run without (fatal) errors.
85-
# To run reliably though, PHPCS 3.5.6 is needed, which undoes the PHP 8.0 comment tokenization changes is needed.
86-
# - PHP 8.1 needs PHPCS 3.5.0+ to run without (fatal) errors.
87-
# To run reliably though, PHPCS 3.5.6 is needed, which undoes the PHP 8.0 comment tokenization changes is needed.
88-
# Additionally, until the new PHP 8.1 "&" tokenization is accounted for in various functions,
89-
# tests will fail in combination with PHPCS < 3.6.1 (in which the new tokenization was undone).
9083
#
9184
# The matrix is set up so as not to duplicate the builds which are run for code coverage.
92-
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
93-
phpcs_version: ['2.6.0', '2.7.1', '2.8.1', '2.9.2', '3.1.0', '3.2.0', '3.3.1', '3.4.2', '3.5.0', '3.5.6', '3.6.0', 'dev-master']
85+
php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
86+
phpcs_version: ['3.7.1', 'dev-master']
9487
risky: [false]
9588
experimental: [false]
9689

97-
exclude:
98-
# Remove the builds which will already be run via quicktest/code coverage.
99-
- php: '5.4'
100-
phpcs_version: '2.6.0'
101-
- php: '5.4'
102-
phpcs_version: 'dev-master'
103-
- php: '7.3'
104-
phpcs_version: '2.9.2'
105-
10690
include:
107-
# Add builds against PHP 8.0/8.1, but only against PHPCS versions which won't fatal out.
108-
- php: '8.0'
109-
phpcs_version: '3.5.6'
110-
risky: false
111-
experimental: false
112-
- php: '8.0'
113-
phpcs_version: '3.6.0'
91+
- php: '5.6'
92+
phpcs_version: '3.7.1'
11493
risky: false
11594
experimental: false
95+
extensions: ':iconv' # Run with iconv disabled.
11696
- php: '8.0'
11797
phpcs_version: 'dev-master'
11898
risky: false
11999
experimental: false
120-
extensions: ':iconv' # Run one build with iconv disabled.
121-
122-
- php: '8.1'
123-
phpcs_version: '3.6.1' # dev-master is run in the code coverage job.
124-
risky: false
125-
experimental: false
100+
extensions: ':iconv' # Run with iconv disabled.
126101

127102
# Experimental builds. These are allowed to fail.
128103
- php: '8.2'
@@ -176,6 +151,10 @@ jobs:
176151
- name: 'Composer: set PHPCS version for tests'
177152
run: composer require --no-update squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}"
178153

154+
# Remove PHPCSDevCS as it would (for now) prevent the tests from being able to run against PHPCS 4.x.
155+
- name: 'Composer: remove PHPCSDevCS'
156+
run: composer remove --dev --no-update phpcsstandards/phpcsdevcs
157+
179158
# Install dependencies and handle caching in one go.
180159
# @link https://github.com/marketplace/actions/install-composer-dependencies
181160
- name: Install Composer dependencies - normal
@@ -228,13 +207,13 @@ jobs:
228207
include:
229208
- php: '8.1'
230209
phpcs_version: 'dev-master'
231-
- php: '7.3'
232-
phpcs_version: '2.9.2'
210+
- php: '8.1'
211+
phpcs_version: '3.7.1'
233212
extensions: ':iconv' # Run one build with iconv disabled.
234213
- php: '5.4'
235214
phpcs_version: 'dev-master'
236215
- php: '5.4'
237-
phpcs_version: '2.6.0'
216+
phpcs_version: '3.7.1'
238217

239218
name: "Coverage: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
240219

@@ -304,6 +283,7 @@ jobs:
304283
PHPCSUTILS_USE_CACHE: false
305284

306285
# Uploading the results with PHP Coveralls v1 won't work from GH Actions, so switch the PHP version.
286+
# Also PHP Coveralls itself (still) isn't fully compatible with PHP 8.0+.
307287
- name: Switch to PHP 7.4
308288
if: ${{ success() && matrix.php != '7.4' }}
309289
uses: shivammathur/setup-php@v2

PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHP_CodeSniffer\Files\File;
1515
use PHP_CodeSniffer\Sniffs\Sniff;
1616
use PHP_CodeSniffer\Util\Tokens;
17-
use PHPCSUtils\BackCompat\BCTokens;
1817
use PHPCSUtils\Utils\Arrays;
1918
use PHPCSUtils\Utils\Numbers;
2019
use PHPCSUtils\Utils\PassedParameters;
@@ -24,6 +23,7 @@
2423
* Abstract sniff to easily examine all parts of an array declaration.
2524
*
2625
* @since 1.0.0
26+
* @since 1.0.0-alpha4 Dropped support for PHPCS < 3.7.1.
2727
*/
2828
abstract class AbstractArrayDeclarationSniff implements Sniff
2929
{
@@ -135,14 +135,14 @@ abstract class AbstractArrayDeclarationSniff implements Sniff
135135
final public function __construct()
136136
{
137137
// Enhance the list of accepted tokens.
138-
$this->acceptedTokens += BCTokens::assignmentTokens();
139-
$this->acceptedTokens += BCTokens::comparisonTokens();
140-
$this->acceptedTokens += BCTokens::arithmeticTokens();
141-
$this->acceptedTokens += BCTokens::operators();
142-
$this->acceptedTokens += BCTokens::booleanOperators();
143-
$this->acceptedTokens += BCTokens::castTokens();
144-
$this->acceptedTokens += BCTokens::bracketTokens();
145-
$this->acceptedTokens += BCTokens::heredocTokens();
138+
$this->acceptedTokens += Tokens::$assignmentTokens;
139+
$this->acceptedTokens += Tokens::$comparisonTokens;
140+
$this->acceptedTokens += Tokens::$arithmeticTokens;
141+
$this->acceptedTokens += Tokens::$operators;
142+
$this->acceptedTokens += Tokens::$booleanOperators;
143+
$this->acceptedTokens += Tokens::$castTokens;
144+
$this->acceptedTokens += Tokens::$bracketTokens;
145+
$this->acceptedTokens += Tokens::$heredocTokens;
146146
}
147147

148148
/**
@@ -483,16 +483,9 @@ public function getActualArrayKey(File $phpcsFile, $startPtr, $endPtr)
483483

484484
// Take PHP 7.4 numeric literal separators into account.
485485
if ($this->tokens[$i]['code'] === \T_LNUMBER || $this->tokens[$i]['code'] === \T_DNUMBER) {
486-
try {
487-
$number = Numbers::getCompleteNumber($phpcsFile, $i);
488-
$content .= $number['content'];
489-
$i = $number['last_token'];
490-
} catch (RuntimeException $e) {
491-
// This must be PHP 3.5.3 with the broken backfill. Let's presume it's a ordinary number.
492-
// If it's not, the sniff will bow out on the following T_STRING anyway if the
493-
// backfill was broken.
494-
$content .= \str_replace('_', '', $this->tokens[$i]['content']);
495-
}
486+
$number = Numbers::getCompleteNumber($phpcsFile, $i);
487+
$content .= $number['content'];
488+
$i = $number['last_token'];
496489
continue;
497490
}
498491

0 commit comments

Comments
 (0)