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

TokensAnalyzer - fix isConstantInvocation #3913

Merged
merged 1 commit into from Aug 19, 2018

Conversation

gharlan
Copy link
Contributor

@gharlan gharlan commented Jul 13, 2018

echo "... $foo[bar] .."

bar is not a constant in this case.

@Slamdunk
Copy link
Contributor

I disagree: https://3v4l.org/PCZG4

Tricky and silly edge case, but still

@gharlan
Copy link
Contributor Author

gharlan commented Jul 14, 2018

@Slamdunk in line 3 bar is a constant. but because the constant does not exist, the string "bar" is used (warning).

In line 5 bar is not a constant (no warning).
The fix here is only about line 5.

@gharlan
Copy link
Contributor Author

gharlan commented Jul 14, 2018

https://3v4l.org/2AroY

@SpacePossum
Copy link
Contributor

we don't have a similar issue with echo "... $foo{bar} .."?

@gharlan
Copy link
Contributor Author

gharlan commented Jul 14, 2018

@SpacePossum it seems not to be valid syntax: https://3v4l.org/RNv7L

@dmvdbrugge
Copy link
Contributor

What about

echo "{$foo[BAR]}";

Is that already covered? I don't see that case tested. Does it make sense to add?

@gharlan
Copy link
Contributor Author

gharlan commented Jul 16, 2018

@dmvdbrugge added your test case.

@gharlan gharlan changed the title TokensAnalyzer: fix isConstantInvocation TokensAnalyzer - fix isConstantInvocation Jul 22, 2018
@SpacePossum SpacePossum added this to the 2.12.3 milestone Jul 28, 2018
@keradus
Copy link
Member

keradus commented Aug 19, 2018

Thank you @gharlan.

@keradus keradus merged commit 53b196c into PHP-CS-Fixer:2.12 Aug 19, 2018
keradus added a commit that referenced this pull request Aug 19, 2018
This PR was squashed before being merged into the 2.12 branch (closes #3913).

Discussion
----------

TokensAnalyzer - fix isConstantInvocation

```php
echo "... $foo[bar] .."
```

`bar` is not a constant in this case.

Commits
-------

53b196c TokensAnalyzer - fix isConstantInvocation
@gharlan gharlan deleted the constant-vs-array branch August 19, 2018 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants