Define PHP 7.4 token constants for downgraded build - #126
Merged
Conversation
Member
Author
|
LGTM, let's ship |
Member
Author
samsonasik
reviewed
Jun 2, 2026
Comment on lines
+33
to
+41
| if (! defined('T_FN')) { | ||
| define('T_FN', 5025); | ||
| } | ||
| if (! defined('T_COALESCE_EQUAL')) { | ||
| define('T_COALESCE_EQUAL', 5030); | ||
| } | ||
| if (! defined('T_BAD_CHARACTER')) { | ||
| define('T_BAD_CHARACTER', 5035); | ||
| } |
Member
There was a problem hiding this comment.
imo, this should be equal with php 8.+ values:
php > echo T_FN;
311
php > echo T_COALESCE_EQUAL;
367
php > echo T_BAD_CHARACTER;
409
Member
Author
There was a problem hiding this comment.
It doesn't really matter, as it's a placeholder value. If it's not existing token value.
5xxx are reserved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The released tool is downgraded to PHP 7.2, but the bundled
nikic/php-parserreferences PHP 7.4 token constants directly. On a real 7.2 runtime this fatals on boot:(plus
constant(): Couldn't find constant T_FN/T_COALESCE_EQUALwarnings)php-parser ships
compatibility_tokens.php, but it only polyfills PHP 8.0+ tokens — the 7.4 ones (T_FN,T_COALESCE_EQUAL,T_BAD_CHARACTER) are assumed to always exist, which is not true once the tool is downgraded to 7.2.Fix
Define the three missing 7.4 token constants in the bin entry point, guarded by
defined()so it is a no-op on PHP 7.4+. Same approach ECS uses inbin/ecs.php.Verification
Ran the patched build on a real PHP 7.2.34 against a project — previously fatal, now: