Confusing error message: Cannot use isset() on the result of an expression (you can use "null !== expression" instead)
未关闭
还没有人认领这个 Issue。
Feature
Status: Needs Triage
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
The following code:
<?php
class X {
const A = '1';
}
$c = 'b';
isset(X::{$c});
Resulted in this (valid) output:
atal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead)
but I cannot use null !== X::{$c}, which also yields a Fatal Error.
With a constant, this message should recommend using 'defined()' instead, or on top of the current recommendation.
PHP Version
Tested on PHP 8.5, but any version since 8.3
Operating System
Not applicable.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先复现使用动态类常量和 isset() 的 PHP 8.5 示例,然后追踪产生所建议的 null 比较的诊断。确定消息可以在哪里考虑常量,并改为建议使用 defined();当该诊断对于此示例是准确的,并且现有行为仍得到覆盖时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 52/100