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

ExplicitStringVariableFixer - wrong behavior for arrays #3943

Closed
gharlan opened this issue Jul 24, 2018 · 1 comment
Closed

ExplicitStringVariableFixer - wrong behavior for arrays #3943

gharlan opened this issue Jul 24, 2018 · 1 comment
Labels

Comments

@gharlan
Copy link
Contributor

gharlan commented Jul 24, 2018

  • before running PHP CS Fixer (no changes):
<?php $a = "My name is $array[MY_CONSTANT] !";
  • with unexpected changes applied when running PHP CS Fixer:
<?php $a = "My name is {$array[MY_CONSTANT]} !";
  • with the changes you expected instead:
<?php $a = "My name is {$array['MY_CONSTANT']} !";

It is a test case from ExplicitStringVariableFixer: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/1c9553ac16b1d10ea891c6f739aa9215d16de024/tests/Fixer/StringNotation/ExplicitStringVariableFixerTest.php#L117-L118

But it is wrong, MY_CONSTANT is not a constant in that case (see #3913), so it needs quotes in the explicit style.

@dmvdbrugge
Copy link
Contributor

When I saw it, this felt off, but the presence of that testcase convinced me it was the correct behaviour 😞 thanks for confirming my doubts and fixing it 😄👍

keradus added a commit that referenced this issue Aug 10, 2018
This PR was merged into the 2.12 branch.

Discussion
----------

ExplicitStringVariableFixer - fix array handling

fixes #3943

Commits
-------

4c2222c ExplicitStringVariableFixer - fix array handling
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