${} is deprecated without documenting new behaviour in PHP 9.0
@iluuu1994 已经在做这个了。
开始于 2022年5月6日。
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
According to this accepted RFC, and according to https://github.com/php/php-src/pull/8212 , the following code is deprecated in PHP 8.2, and is scheduled for removal in PHP 9.0:
<?php
var_dump("${foo}");
// Deprecated: Using ${} in strings is deprecated
var_dump("${(foo)}");
// Deprecated: Using ${} (variable variables) in strings is deprecated
However, this RFC does not document what the behaviour will be in PHP 9.0. Will it raise a syntax error? Or will treat it like a plain string literal?
<?php
var_dump("${foo}");
// In PHP 9.0, will this raise a syntax error? Or will it be equal to '${foo}' ?
var_dump("${(foo)}");
// In PHP 9.0, will this raise a syntax error? Or will it be equal to '${(foo)}' ?
I think this is important to consider this question to help those migrating their codebase to PHP 9.0 in the future, and to alert those who may not realise this code may need modification. I personally propose that this raise a syntax error in PHP 9.0. Later versions can allow this syntax again, if needed, with the new behaviour of acting like a normal string literal with no special behaviour. This means that the migration path would be:
- Old syntax is supported
- Old syntax raises a deprecation warning, but works as before (PHP 8.2)
- Old syntax raises a syntax error (PHP 9.0)
- In the future, the old syntax may be allowed again, with the new behaviour
PHP Version
PHP 8.2
Operating System
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
评估
这个 Issue 还没有评估数据。