Hi everyone
It was pointed out to me that unfortunately the "Deprecate ${} string
interpolation" RFC didn't specify how the feature would be removed
in PHP 9.
https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
https://github.com/php/php-src/issues/8501
There are two approaches:
- Completely remove the syntax and make "${}" result in the literal string "${}"
- Keep the syntax in the parser but throw an error
It's pretty clear to me that the latter is preferable for two reasons:
- People upgrading directly from <=PHP 8.1 to PHP 9.0 or people who
have not addressed the deprecations will still get an appropriate
compile-time error message instead of their code suddenly behaving
differently. - We can reuse the syntax at some point without causing another BC break.
The only advantage of the former approach I can think of is easier (or
rather no) escaping of ${} in strings but this could also be a
drawback considering that it would become unclear what the original
intent of the code was (literal output or string interpolation).
So unless there are concerns I will amend that in the RFC.
Regards,
Ilija
Hi everyone
It was pointed out to me that unfortunately the "Deprecate ${} string
interpolation" RFC didn't specify how the feature would be removed
in PHP 9.https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
https://github.com/php/php-src/issues/8501There are two approaches:
- Completely remove the syntax and make "${}" result in the literal string "${}"
- Keep the syntax in the parser but throw an error
It's pretty clear to me that the latter is preferable for two reasons:
- People upgrading directly from <=PHP 8.1 to PHP 9.0 or people who
have not addressed the deprecations will still get an appropriate
compile-time error message instead of their code suddenly behaving
differently.- We can reuse the syntax at some point without causing another BC break.
The only advantage of the former approach I can think of is easier (or
rather no) escaping of ${} in strings but this could also be a
drawback considering that it would become unclear what the original
intent of the code was (literal output or string interpolation).So unless there are concerns I will amend that in the RFC.
Regards,
Ilija
In my reading of the RFC, I assumed the first approach: completely
remove the syntax and make "${}" result in the literal string "${}".
IMO, this is not an insignificant change to the RFC. I'd like to hear
from those who voted on the RFC before you make this change.
Cheers,
Ben
So unless there are concerns I will amend that in the RFC.
Erroring it out makes sense to me.
As we don't include any target version specification in PHP files, the
safest bet it so prevent the silent change from potentially leaking
through the introduction of a parser error.