-
Notifications
You must be signed in to change notification settings - Fork 84
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
Syntax error with array access in string interpolation #62
Comments
You actually need to always put those single quotes in. The other code you have will generate a warning saying constant 'foo' undefined, treated as string, in PHP 5 and 7, and in PHP 8 will be a hard error. |
So, this is actually not a bug, and it is doing the correct thing, to escape the constant to the global namespace with a slash. |
AFAIK string interpolation has different rules, e.g. theres two are different: $a = ['foo' => 'bar'];
print $a[foo]; // references a nonexistant constant, emits a warning
print "$a[foo]"; // "knows" the context, this does not emit a warning See https://www.php.net/manual/en/language.types.string.php Example 10 which uses this syntax. I tried it with a PHP 8 Docker image too:
|
Ah, yes. You are right! Hmmm. There is a bug here then. 👍 |
Hello there, https://github.com/n00dl3/opis-closure-tests I also tried with @abdrzakoxa PR (branch Maybe I should open a new issue ? |
Yes, please open a new issue. It would have been very helpful to put those tests directly inside opis/closure :) |
Ok, I've found the problem, a fix is coming in the next minutes. |
Yeah, sorry, I started with a single test case and it grew up very quickly... |
String interpolation error was solved in 85fec0b This issue (with array access) is not solved yet. |
Hello @sorinsarca |
@abdrzakoxa I'm looking at that PR right now. |
I have only used this library through another library, but here's a reproducible code:
Result (version 3.5.5):
Result (commit 82cc21f):
I think the problematic commit is c17ece0
Of course a workaround is to "fix" all interpolations like this with
The text was updated successfully, but these errors were encountered: