Skip to content

Commit af9fb65

Browse files
jrfnlgrogy
authored andcommitted
Bring back support for PHP 5.3
As Parallel Lint supports PHP 5.3 again since [PR 51](php-parallel-lint/PHP-Parallel-Lint#51), it would be helpful for the Highlighter repo to also support PHP 5.3. This restores the PHP 5.3 minimum version along the same lines as before the version drop in 02b6aa6 The PHP 5.3.2 minimum is in-line with the PHP Console Color minimum version for PHP 5.3. Includes: * Enabling a build against PHP 5.3 in the GH Actions workflow. * Adjusting the `testVersion` for the PHPCompatibility checks to `5.3-` (5.3 and higher).
1 parent a16b277 commit af9fb65

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

.github/workflows/test.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
strategy:
2020
matrix:
21-
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
21+
php: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
2222
experimental: [false]
2323

2424
include:
@@ -40,6 +40,11 @@ jobs:
4040
coverage: none
4141
tools: cs2pr
4242

43+
# Remove the PHPCS standard as it has a minimum PHP requirements of PHP 5.4 and would block install on PHP 5.3.
44+
- name: 'Composer: remove PHPCS'
45+
if: ${{ matrix.php < 5.4 }}
46+
run: composer remove --dev php-parallel-lint/php-code-style --no-update --no-interaction
47+
4348
# Install dependencies and handle caching in one go.
4449
# @link https://github.com/marketplace/actions/install-composer-dependencies
4550
- name: Install Composer dependencies - normal

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"psr-4": {"PHP_Parallel_Lint\\PhpConsoleHighlighter\\Test\\": "tests/"}
1818
},
1919
"require": {
20-
"php": ">=5.4.0",
20+
"php": ">=5.3.2",
2121
"ext-tokenizer": "*",
22-
"php-parallel-lint/php-console-color": "^1.0"
22+
"php-parallel-lint/php-console-color": "^1.0.1"
2323
},
2424
"require-dev": {
2525
"phpunit/phpunit": "^4.8.36 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",

phpcs.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
-->
3737

3838
<!-- Set the supported PHP versions for PHPCompatibility (included in PHPParallelLint). -->
39-
<config name="testVersion" value="5.4-"/>
39+
<config name="testVersion" value="5.3-"/>
4040

4141
<rule ref="PHPParallelLint"/>
4242

src/Highlighter.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class Highlighter
4646
T_FUNC_C => T_FUNC_C,
4747
T_METHOD_C => T_METHOD_C,
4848
T_NS_C => T_NS_C,
49-
T_TRAIT_C => T_TRAIT_C,
5049
);
5150

5251
/** @var array */
@@ -214,6 +213,12 @@ private function getTokenType($arrayToken)
214213

215214
// phpcs:disable PHPCompatibility.Constants.NewConstants -- The new token constants are only used when defined.
216215

216+
// Traits didn't exist in PHP 5.3 yet, so the trait magic constant needs special casing for PHP >= 5.4.
217+
// __TRAIT__ will tokenize as T_STRING in PHP 5.3, so, the end result will be the same cross-version.
218+
if (defined('T_TRAIT_C') && $arrayToken[0] === T_TRAIT_C) {
219+
return self::TOKEN_DEFAULT;
220+
}
221+
217222
// Handle PHP >= 8.0 namespaced name tokens.
218223
// https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.tokenizer
219224
if (

0 commit comments

Comments
 (0)