Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4787f19
Drop support for PHPCS < 3.7.1
jrfnl Sep 30, 2022
9f8ba46
Test bootstrap: remove condition related to PHPCS 2.x
jrfnl Sep 30, 2022
6147ab7
Composer: add PHPCSDevCS to the dependencies
jrfnl Sep 30, 2022
865a39f
BackCompat\Helper: remove support for PHPCS 2.x
jrfnl Sep 30, 2022
d29761b
BackCompat\BCTokens: remove support for PHPCS < 3.7.1
jrfnl Oct 2, 2022
06fa948
Utils: minor efficiency tweak after BCTokens cleanup
jrfnl Oct 2, 2022
1bd5a8d
BackCompat\BCFile: remove support for PHPCS < 3.7.1
jrfnl Oct 3, 2022
58cfce1
Fixers\SpacesFixer: remove support for PHPCS < 3.7.1
jrfnl Oct 10, 2022
c8a438e
TestUtils\UtilityMethodTestCase: remove support for PHPCS < 3.7.1
jrfnl Oct 6, 2022
3abea99
Tokens\TokenHelper\TokenExistsTest: remove three tests
jrfnl Oct 6, 2022
12172e2
Utils\Arrays: remove support for PHPCS < 3.7.1
jrfnl Oct 7, 2022
e9cd164
Utils\ControlStructures: remove support for PHPCS < 3.7.1
jrfnl Oct 9, 2022
e3a8ce9
Utils\Lists: remove support for PHPCS < 3.7.1
jrfnl Oct 10, 2022
c6fb2de
Utils\MessageHelper::hasNewLineSupport(): remove the method
jrfnl Oct 9, 2022
4b1bc7a
Utils\Namespaces: remove support for PHPCS < 3.7.1
jrfnl Oct 7, 2022
e39b374
Utils\Parentheses: remove support for PHPCS < 3.7.1
jrfnl Oct 6, 2022
38cbcfc
Utils\PassedParameters: remove support for PHPCS < 3.7.1
jrfnl Oct 9, 2022
231e195
Utils\ObjectDeclarations: remove support for PHPCS < 3.7.1
jrfnl Oct 6, 2022
4f32289
Utils\TextStrings: remove support for PHPCS < 3.7.1
jrfnl Oct 12, 2022
e2d9093
Utils\UseStatements: remove support for PHPCS < 3.7.1
jrfnl Oct 7, 2022
da1ea05
Utils\Variables: remove support for PHPCS < 3.7.1
jrfnl Oct 7, 2022
c6b0a99
Utils\Operators::isTypeUnion(): remove the method
jrfnl Oct 8, 2022
dc69ffe
Tokens\Collections: remove the work-arounds which were in place to su…
jrfnl Oct 8, 2022
ca96ca9
Utils\Operators::isNullsafeObjectOperator(): remove the method
jrfnl Oct 8, 2022
2f33ac4
Tokens\Collections: remove the `nullsafeObjectOperatorBC()` and the `…
jrfnl Oct 8, 2022
232d1f0
Utils\Operators: remove support for PHPCS < 3.7.1
jrfnl Oct 7, 2022
1cf6a8c
Utils\Numbers: remove support for PHPCS < 3.7.1
jrfnl Oct 8, 2022
b5d170e
Utils\FunctionDeclarations: remove support for PHPCS < 3.7.1
jrfnl Oct 5, 2022
282f6a4
Tokens\Collections: deprecate the work-arounds which were in place to…
jrfnl Oct 10, 2022
f7cc50a
Tokens\Collections: deprecate the parameterTypeTokensBC() method
jrfnl Oct 11, 2022
d428a82
Tokens\Collections: deprecate the propertyTypeTokensBC() method
jrfnl Oct 11, 2022
20d072e
Tokens\Collections: deprecate the returnTypeTokensBC() method
jrfnl Oct 11, 2022
3b413c1
Tokens\Collections: remove remaining work-arounds for PHPCS < 3.7.1
jrfnl Oct 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/basics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ jobs:
composer remove --no-update --dev phpunit/phpunit --no-scripts
# Using PHPCS `master` as an early detection system for bugs upstream.
composer require --no-update squizlabs/php_codesniffer:"dev-master"
# Add PHPCSDevCS - this is the CS ruleset we use.
# This is not in the composer.json as it has different minimum PHPCS reqs and would conflict.
composer require --no-update --dev phpcsstandards/phpcsdevcs:"^1.1.3"

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ jobs:
quicktest:
runs-on: ubuntu-latest

env:
# - COMPOSER_ROOT_VERSION is needed to get round the recursive dependency when using CI.
COMPOSER_ROOT_VERSION: '1.99.99'

strategy:
matrix:
php: ['5.4', 'latest']
phpcs_version: ['dev-master']

include:
- php: '7.3'
phpcs_version: '2.9.2'
- php: '5.4'
phpcs_version: '2.6.0'
phpcs_version: ['3.7.1', 'dev-master']

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

Expand Down
56 changes: 18 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# - COMPOSER_ROOT_VERSION is needed to get round the recursive dependency when using CI.
COMPOSER_ROOT_VERSION: '1.99.99'

jobs:
lint:
if: ${{ github.ref != 'refs/heads/develop' }}
Expand Down Expand Up @@ -76,53 +80,24 @@ jobs:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
#
# IMPORTANT: test runs shouldn't fail because of PHPCS being incompatible with a PHP version.
# - PHPCS will run without errors on PHP 5.4 - 7.2 on any version.
# - PHP 7.3 needs PHPCS 2.9.2 and 3.3.1+ to run without notices.
# As deprecations are ignored for older PHPCS versions, our tests still shouldn't fail.
# - PHP 7.4 needs PHPCS 3.5.0+ to run without notices.
# As deprecations are ignored for older PHPCS versions, our tests still shouldn't fail.
# - PHP 8.0 needs PHPCS 3.5.0+ to run without (fatal) errors.
# To run reliably though, PHPCS 3.5.6 is needed, which undoes the PHP 8.0 comment tokenization changes is needed.
# - PHP 8.1 needs PHPCS 3.5.0+ to run without (fatal) errors.
# To run reliably though, PHPCS 3.5.6 is needed, which undoes the PHP 8.0 comment tokenization changes is needed.
# Additionally, until the new PHP 8.1 "&" tokenization is accounted for in various functions,
# tests will fail in combination with PHPCS < 3.6.1 (in which the new tokenization was undone).
#
# The matrix is set up so as not to duplicate the builds which are run for code coverage.
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
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']
php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
phpcs_version: ['3.7.1', 'dev-master']
risky: [false]
experimental: [false]

exclude:
# Remove the builds which will already be run via quicktest/code coverage.
- php: '5.4'
phpcs_version: '2.6.0'
- php: '5.4'
phpcs_version: 'dev-master'
- php: '7.3'
phpcs_version: '2.9.2'

include:
# Add builds against PHP 8.0/8.1, but only against PHPCS versions which won't fatal out.
- php: '8.0'
phpcs_version: '3.5.6'
risky: false
experimental: false
- php: '8.0'
phpcs_version: '3.6.0'
- php: '5.6'
phpcs_version: '3.7.1'
risky: false
experimental: false
extensions: ':iconv' # Run with iconv disabled.
- php: '8.0'
phpcs_version: 'dev-master'
risky: false
experimental: false
extensions: ':iconv' # Run one build with iconv disabled.

- php: '8.1'
phpcs_version: '3.6.1' # dev-master is run in the code coverage job.
risky: false
experimental: false
extensions: ':iconv' # Run with iconv disabled.

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

# Remove PHPCSDevCS as it would (for now) prevent the tests from being able to run against PHPCS 4.x.
- name: 'Composer: remove PHPCSDevCS'
run: composer remove --dev --no-update phpcsstandards/phpcsdevcs

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies - normal
Expand Down Expand Up @@ -228,13 +207,13 @@ jobs:
include:
- php: '8.1'
phpcs_version: 'dev-master'
- php: '7.3'
phpcs_version: '2.9.2'
- php: '8.1'
phpcs_version: '3.7.1'
extensions: ':iconv' # Run one build with iconv disabled.
- php: '5.4'
phpcs_version: 'dev-master'
- php: '5.4'
phpcs_version: '2.6.0'
phpcs_version: '3.7.1'

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

Expand Down Expand Up @@ -304,6 +283,7 @@ jobs:
PHPCSUTILS_USE_CACHE: false

# Uploading the results with PHP Coveralls v1 won't work from GH Actions, so switch the PHP version.
# Also PHP Coveralls itself (still) isn't fully compatible with PHP 8.0+.
- name: Switch to PHP 7.4
if: ${{ success() && matrix.php != '7.4' }}
uses: shivammathur/setup-php@v2
Expand Down
31 changes: 12 additions & 19 deletions PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Util\Tokens;
use PHPCSUtils\BackCompat\BCTokens;
use PHPCSUtils\Utils\Arrays;
use PHPCSUtils\Utils\Numbers;
use PHPCSUtils\Utils\PassedParameters;
Expand All @@ -24,6 +23,7 @@
* Abstract sniff to easily examine all parts of an array declaration.
*
* @since 1.0.0
* @since 1.0.0-alpha4 Dropped support for PHPCS < 3.7.1.
*/
abstract class AbstractArrayDeclarationSniff implements Sniff
{
Expand Down Expand Up @@ -135,14 +135,14 @@ abstract class AbstractArrayDeclarationSniff implements Sniff
final public function __construct()
{
// Enhance the list of accepted tokens.
$this->acceptedTokens += BCTokens::assignmentTokens();
$this->acceptedTokens += BCTokens::comparisonTokens();
$this->acceptedTokens += BCTokens::arithmeticTokens();
$this->acceptedTokens += BCTokens::operators();
$this->acceptedTokens += BCTokens::booleanOperators();
$this->acceptedTokens += BCTokens::castTokens();
$this->acceptedTokens += BCTokens::bracketTokens();
$this->acceptedTokens += BCTokens::heredocTokens();
$this->acceptedTokens += Tokens::$assignmentTokens;
$this->acceptedTokens += Tokens::$comparisonTokens;
$this->acceptedTokens += Tokens::$arithmeticTokens;
$this->acceptedTokens += Tokens::$operators;
$this->acceptedTokens += Tokens::$booleanOperators;
$this->acceptedTokens += Tokens::$castTokens;
$this->acceptedTokens += Tokens::$bracketTokens;
$this->acceptedTokens += Tokens::$heredocTokens;
}

/**
Expand Down Expand Up @@ -483,16 +483,9 @@ public function getActualArrayKey(File $phpcsFile, $startPtr, $endPtr)

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

Expand Down
Loading