Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dollar sign from variable name swallowed in double quoted Strings #2177

Open
FrankNagel opened this issue May 11, 2023 · 1 comment
Open
Labels

Comments

@FrankNagel
Copy link

@prettier/plugin-php v0.19.4
Playground link

Input:

<?php

# simple syntax
# OK
"$foo[$index_var]";

# simple syntax with explicit name boundaries with curly brackets
# Not OK: prettier swallows the dollar sign from $index_var
"${foo[$index_var]}";

# complex (curly) syntax
# OK
"{$foo[$index_var]}";

Output:

<?php

# simple syntax
# OK
"$foo[$index_var]";

# simple syntax with explicit name boundaries with curly brackets
# Not OK: prettier swallows the dollar sign from $index_var
"${foo[index_var]}";

# complex (curly) syntax
# OK
"{$foo[$index_var]}";

In a double quoted string using the so called simple syntax with explicit variable boundaries given by curly brackets prettier swallows the dollar sign from a variable nested inside the boundaries.

@czosel czosel added the bug label May 11, 2023
@cseufert
Copy link
Collaborator

The "${a}" syntax is now deprecated, with a plan to remove it in future PHP versions.
see: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants