Skip to content

Commit c216317

Browse files
authored
Merge pull request #746 from PHPCSStandards/develop
Release 1.2.2
2 parents d71128c + f9bec0d commit c216317

File tree

14 files changed

+191
-55
lines changed

14 files changed

+191
-55
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ updates:
88
- package-ecosystem: "github-actions"
99
directory: "/"
1010
schedule:
11-
interval: "weekly"
11+
interval: "cron"
12+
cronjob: "10 22 5,20 * *" # At 22:10, every 5th and 20th day of the month.
1213
open-pull-requests-limit: 5
1314
commit-message:
1415
prefix: "GH Actions:"

.github/workflows/basics.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ jobs:
2626

2727
steps:
2828
- name: Checkout code
29-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
29+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3030
with:
3131
persist-credentials: false
3232

3333
- name: Install PHP
34-
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
34+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
3535
with:
3636
php-version: 'latest'
3737
coverage: none

.github/workflows/quicktest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050

5151
steps:
5252
- name: Checkout code
53-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
53+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
5454
with:
5555
persist-credentials: false
5656

@@ -66,7 +66,7 @@ jobs:
6666
fi
6767
6868
- name: Install PHP
69-
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
69+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
7070
with:
7171
php-version: ${{ matrix.php }}
7272
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}

.github/workflows/test.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ jobs:
3030

3131
strategy:
3232
matrix:
33-
php: ['5.4', '7.0', '7.4', '8.0', '8.4', '8.5']
33+
php: ['5.4', '7.0', '7.4', '8.0', '8.5', 'nightly']
3434

3535
name: "Lint: PHP ${{ matrix.php }}"
3636

37-
continue-on-error: ${{ matrix.php == '8.5' }}
37+
continue-on-error: ${{ matrix.php == 'nightly' }}
3838

3939
steps:
4040
- name: Checkout code
41-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
41+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
4242
with:
4343
persist-credentials: false
4444

4545
- name: Install PHP
46-
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
46+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
4747
with:
4848
php-version: ${{ matrix.php }}
4949
ini-file: 'development'
@@ -54,16 +54,16 @@ jobs:
5454
uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1
5555
with:
5656
# For PHP "nightly", we need to install with ignore platform reqs as not all dependencies may allow it yet.
57-
composer-options: ${{ matrix.php == '8.5' && '--ignore-platform-req=php+' || '' }}
57+
composer-options: ${{ matrix.php == 'nightly' && '--ignore-platform-req=php+' || '' }}
5858
# Bust the cache at least once a month - output format: YYYY-MM.
5959
custom-cache-suffix: $(date -u "+%Y-%m")
6060

6161
- name: "Lint against parse errors (PHP < 7.2)"
62-
if: ${{ matrix.php < 7.2 }}
62+
if: ${{ matrix.php < 7.2 && matrix.php != 'nightly' }}
6363
run: composer lint-lt72 -- --checkstyle | cs2pr
6464

6565
- name: "Lint against parse errors (PHP 7.2+)"
66-
if: ${{ matrix.php >= 7.2 }}
66+
if: ${{ matrix.php >= 7.2 || matrix.php == 'nightly' }}
6767
run: composer lint -- --checkstyle | cs2pr
6868

6969

@@ -86,7 +86,7 @@ jobs:
8686
# IMPORTANT: test runs shouldn't fail because of PHPCS being incompatible with a PHP version.
8787
#
8888
# The matrix is set up so as not to duplicate the builds which are run for code coverage.
89-
php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
89+
php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
9090
phpcs_version: ['lowest', '3.x-dev', '4.0.1', '4.x-dev']
9191
risky: [false]
9292
experimental: [false]
@@ -127,11 +127,11 @@ jobs:
127127
extensions: ':iconv' # Run with iconv disabled.
128128

129129
# Experimental builds. These are allowed to fail.
130-
- php: '8.5'
130+
- php: '8.6'
131131
phpcs_version: '3.x-dev'
132132
risky: false
133133
experimental: true
134-
- php: '8.5'
134+
- php: '8.6'
135135
phpcs_version: '4.x-dev'
136136
risky: false
137137
experimental: true
@@ -152,22 +152,22 @@ jobs:
152152
risky: true
153153
experimental: true
154154

155-
- php: '8.4'
155+
- php: '8.5'
156156
phpcs_version: 'lowest'
157157
risky: true
158158
experimental: true
159159

160-
- php: '8.4'
160+
- php: '8.5'
161161
phpcs_version: '3.x-dev'
162162
risky: true
163163
experimental: true
164164

165-
- php: '8.4'
165+
- php: '8.5'
166166
phpcs_version: '4.0.1'
167167
risky: true
168168
experimental: true
169169

170-
- php: '8.4'
170+
- php: '8.5'
171171
phpcs_version: '4.x-dev'
172172
risky: true
173173
experimental: true
@@ -178,7 +178,7 @@ jobs:
178178

179179
steps:
180180
- name: Checkout code
181-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
181+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
182182
with:
183183
persist-credentials: false
184184

@@ -194,7 +194,7 @@ jobs:
194194
fi
195195
196196
- name: Install PHP
197-
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
197+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
198198
with:
199199
php-version: ${{ matrix.php }}
200200
extensions: ${{ matrix.extensions }}
@@ -219,7 +219,7 @@ jobs:
219219
uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1
220220
with:
221221
# For PHP "nightly", we need to install with ignore platform reqs as not all dependencies may allow it yet.
222-
composer-options: ${{ matrix.php == '8.5' && '--ignore-platform-req=php+' || '' }}
222+
composer-options: ${{ matrix.php == '8.6' && '--ignore-platform-req=php+' || '' }}
223223
# Bust the cache at least once a month - output format: YYYY-MM.
224224
custom-cache-suffix: $(date -u "+%Y-%m")
225225

@@ -295,14 +295,14 @@ jobs:
295295
strategy:
296296
matrix:
297297
include:
298-
- php: '8.4'
298+
- php: '8.5'
299299
phpcs_version: '4.x-dev'
300300
extensions: ':iconv' # Run one build with iconv disabled.
301-
- php: '8.4'
301+
- php: '8.5'
302302
phpcs_version: '4.0.1'
303-
- php: '8.4'
303+
- php: '8.5'
304304
phpcs_version: '3.x-dev'
305-
- php: '8.4'
305+
- php: '8.5'
306306
phpcs_version: 'lowest'
307307
- php: '7.2'
308308
phpcs_version: '4.x-dev'
@@ -317,7 +317,7 @@ jobs:
317317

318318
steps:
319319
- name: Checkout code
320-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
320+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
321321
with:
322322
persist-credentials: false
323323

@@ -333,7 +333,7 @@ jobs:
333333
fi
334334
335335
- name: Install PHP
336-
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
336+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
337337
with:
338338
php-version: ${{ matrix.php }}
339339
extensions: ${{ matrix.extensions }}
@@ -398,7 +398,7 @@ jobs:
398398

399399
- name: Upload coverage results to Coveralls
400400
if: ${{ success() }}
401-
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
401+
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7
402402
with:
403403
format: clover
404404
file: build/logs/clover.xml
@@ -415,6 +415,6 @@ jobs:
415415

416416
steps:
417417
- name: Coveralls Finished
418-
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
418+
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7
419419
with:
420420
parallel-finished: true

.github/workflows/update-docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ jobs:
5858
fi
5959
6060
- name: Checkout code
61-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
61+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
6262
with:
6363
ref: ${{ steps.base_branch.outputs.BRANCH }}
6464
# fetch-depth is needed to allow for retrieving the last tag for a non-tag workflow run.
6565
fetch-depth: 0
6666
persist-credentials: false
6767

6868
- name: Install PHP
69-
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
69+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
7070
with:
7171
# Use a version known to be safe for last phpDocumentor release.
72-
php-version: '8.1'
72+
php-version: '8.4'
7373
ini-file: 'development'
7474
coverage: none
7575
# Install the latest phpDocumentor release as a PHAR.

.github/workflows/update-phpcs-versionnr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
echo "PR_BRANCH=feature/getversiontest-update-phpcs-version" >> "$GITHUB_OUTPUT"
5353
5454
- name: Checkout code
55-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
55+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
5656
with:
5757
ref: ${{ steps.branches.outputs.BASE }}
5858
persist-credentials: false
@@ -79,7 +79,7 @@ jobs:
7979
run: git status -vv --untracked=all
8080

8181
- name: Create pull request
82-
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
82+
uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.11
8383
with:
8484
base: ${{ steps.branches.outputs.BASE }}
8585
branch: ${{ steps.branches.outputs.PR_BRANCH }}

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,35 @@ This projects adheres to [Keep a CHANGELOG](https://keepachangelog.com/) and use
1010
_Nothing yet._
1111

1212

13+
## [1.2.2] - 2025-12-08
14+
15+
### Added
16+
17+
#### PHPCS Backcompat
18+
19+
* `BCTokens::castTokens()`: sync with PHPCS 4.0.2 - added the `T_VOID_CAST` token (when available). [#742]
20+
21+
### Changed
22+
23+
#### Utils
24+
25+
* `FunctionDeclarations::getProperties()`: more defensive coding against parse errors/live coding. [#740]
26+
27+
#### Other
28+
29+
* Various housekeeping.
30+
31+
[#740]: https://github.com/PHPCSStandards/PHPCSUtils/pull/740
32+
[#742]: https://github.com/PHPCSStandards/PHPCSUtils/pull/742
33+
34+
1335
## [1.2.1] - 2025-11-17
1436

1537
### Fixed
1638

1739
#### Abstract Sniffs
1840

19-
* The `AbstractArrayDeclarationSniff::getActualArrayKey()` method could cause deprecation notices and even fatal errors, when a PHPCS scan would be run on a different PHP version than the "code under scan" is targetting and the "code under scan" contained deprecated/removed type casts. [#733]
41+
* The `AbstractArrayDeclarationSniff::getActualArrayKey()` method could cause deprecation notices and even fatal errors, when a PHPCS scan would be run on a different PHP version than the "code under scan" is targeting and the "code under scan" contained deprecated/removed type casts. [#733]
2042

2143
[#733]: https://github.com/PHPCSStandards/PHPCSUtils/pull/733
2244

@@ -1333,6 +1355,7 @@ This initial alpha release contains the following utility classes:
13331355

13341356

13351357
[Unreleased]: https://github.com/PHPCSStandards/PHPCSUtils/compare/stable...HEAD
1358+
[1.2.2]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.2.1...1.2.2
13361359
[1.2.1]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.2.0...1.2.1
13371360
[1.2.0]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.1.3...1.2.0
13381361
[1.1.3]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.1.2...1.1.3

PHPCSUtils/BackCompat/BCTokens.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
* @method static array<int|string, int|string> arithmeticTokens() Tokens that represent arithmetic operators.
4747
* @method static array<int|string, int|string> booleanOperators() Tokens that perform boolean operations.
4848
* @method static array<int|string, int|string> bracketTokens() Tokens that represent brackets and parenthesis.
49-
* @method static array<int|string, int|string> castTokens() Tokens that represent type casting.
5049
* @method static array<int|string, int|string> commentTokens() Tokens that are comments.
5150
* @method static array<int|string, int|string> comparisonTokens() Tokens that represent comparison operator.
5251
* @method static array<int|string, int|string> contextSensitiveKeywords() Tokens representing context sensitive keywords
@@ -144,6 +143,31 @@ public static function blockOpeners()
144143
return $tokens;
145144
}
146145

146+
/**
147+
* Tokens that represent casting.
148+
*
149+
* Retrieve the PHPCS cast tokens array in a cross-version compatible manner.
150+
*
151+
* Changelog for the PHPCS native array:
152+
* - PHPCS 4.0.2: The PHP 8.5 T_VOID_CAST token was added.
153+
*
154+
* @see \PHP_CodeSniffer\Util\Tokens::$castTokens Original array.
155+
*
156+
* @since 1.2.1
157+
*
158+
* @return array<int|string, int|string> Token array.
159+
*/
160+
public static function castTokens()
161+
{
162+
$tokens = Tokens::$castTokens;
163+
164+
if (\defined('T_VOID_CAST')) {
165+
$tokens[\T_VOID_CAST] = \T_VOID_CAST;
166+
}
167+
168+
return $tokens;
169+
}
170+
147171
/**
148172
* Tokens that represent the names of called functions.
149173
*

PHPCSUtils/Utils/FunctionDeclarations.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public static function getName(File $phpcsFile, $stackPtr)
150150
* - `"has_body"` index could be set to `true` for functions without body in the case of
151151
* parse errors or live coding.
152152
* - Defensive coding against incorrect calls to this method.
153+
* - Defensive coding against incorrect results due to parse errors in the code under scan.
153154
* - More efficient checking whether a function has a body.
154155
* - Support for PHP 8.0 identifier name tokens in return types, cross-version PHP & PHPCS.
155156
* - The results of this function call are cached during a PHPCS run for faster response times.
@@ -277,7 +278,10 @@ public static function getProperties(File $phpcsFile, $stackPtr)
277278
break;
278279
}
279280

280-
if ($scopeOpener === null && $tokens[$i]['code'] === \T_SEMICOLON) {
281+
if ($scopeOpener === null
282+
&& ($tokens[$i]['code'] === \T_SEMICOLON
283+
|| $tokens[$i]['code'] === \T_OPEN_CURLY_BRACKET)
284+
) {
281285
// End of abstract/interface function definition.
282286
break;
283287
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
[![Coverage Status](https://coveralls.io/repos/github/PHPCSStandards/PHPCSUtils/badge.svg?branch=develop)](https://coveralls.io/github/PHPCSStandards/PHPCSUtils?branch=develop)
1515

1616
[![Minimum PHP Version](https://img.shields.io/packagist/dependency-v/phpcsstandards/phpcsutils/php.svg)][phpcsutils-packagist]
17-
[![Tested on PHP 5.4 to 8.4](https://img.shields.io/badge/tested%20on-PHP%205.4%20|%205.5%20|%205.6%20|%207.0%20|%207.1%20|%207.2%20|%207.3%20|%207.4%20|%208.0%20|%208.1%20|%208.2%20|%208.3%20|%208.4-brightgreen.svg?maxAge=2419200)][phpcsutils-tests-gha]
17+
[![Tested on PHP 5.4 to 8.5](https://img.shields.io/badge/tested%20on-PHP%205.4%20|%205.5%20|%205.6%20|%207.0%20|%207.1%20|%207.2%20|%207.3%20|%207.4%20|%208.0%20|%208.1%20|%208.2%20|%208.3%20|%208.4%20|%208.5-brightgreen.svg?maxAge=2419200)][phpcsutils-tests-gha]
1818

1919
[![License: LGPLv3](https://img.shields.io/github/license/PHPCSStandards/PHPCSUtils)](https://github.com/PHPCSStandards/PHPCSUtils/blob/stable/LICENSE)
2020
![Awesome](https://img.shields.io/badge/awesome%3F-yes!-brightgreen.svg)

0 commit comments

Comments
 (0)