php / php/php-src

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

未关闭
#14,937 11 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Extension: tokenizer Status: Verified
主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 15 小时
30 天内合并 PR
103

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,在报告中列出的各个 PHP 8.3 补丁版本上,通过 token_get_all 重现不同的 T_STRING 值。跟踪 Bison 解析器如何生成 zendtokentype 常量,并比较这些版本之间生成的结果;当 PHP 8.3 各补丁版本之间的 token 常量保持稳定时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
c, php
领域
compilers
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。