php / php/php-src

Bison parser generates different zendtokentype constants for each patch version since php 8.3.

Open
#14,937 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Extension: tokenizer Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Hi, I noticed that since PHP 8.3 the value of T_* constants changes for each patch version. For example, if I'll use token_get_all and cache or serialize returning result I can got unexpected behavior.

https://3v4l.org/8L2eX

<?php

$text = <<<TXT
<?php

namespace AAA;

require_once '/tmp/dev2/t4.php';
class AAA {
}

\$class = new AAA();
TXT;

$tokens = token_get_all($text);

foreach ($tokens as $token) {
    echo json_encode($token) . "\n";
}

For example
T_STRING constant is 313 for 8.3.0, 8.3.2, 8.3.4, 8.3.7, 8.3.9 versions.
T_STRING constant is 262 for 8.3.1, 8.3.3, 8.3.5 - 8.3.6, 8.3.8 versions.

However for 8.1, 8.2 there are not changes between php patch versions.

PHP Version

8.3

Operating System

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the differing T_STRING values through token_get_all across the PHP 8.3 patch versions listed in the report. Trace how the Bison parser generates the zendtokentype constants and compare the generated results across those versions; done means token constants remain stable between PHP 8.3 patch releases.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.