-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
PHP 8.0+ does no longer accept a comment in the whitespace between ampersand and argument in function signature #10083
Comments
This is expected and caused by some parser/tokenizer hackery for intersection types that was necessary to avoid ambiguity. See 069a9fa. |
Won't fix = impossible to fix? |
Yes 🙂 |
😢 |
I think in theory we could adjust the tokens so that variables are assumed after |
Are comments part of the token stream? That's the problem? Because whitespace and newline works fine. |
No. The problem is that the grammar is ambiguous. Our LR(1) parser only gets one token of lookahead, but code like php-src/Zend/zend_language_scanner.l Lines 1872 to 1879 in b96b88b
|
Ah ok. But expanding |
I suppose, yes. Currently lexing of comments is more complex although fully expressable via regex. I guess if we can embed those as lookahead it would work fine. |
Let's reopen until we verify that this approach will or won't work. |
Yep, can do, thanks! |
To be clear, this appears to have been found during someone doing code-golf. It doesn't appear to affect an in production codebase. |
Possibly this. But does not match newlines inside /* */ comments. :/ |
Attempted fix #10084 showed this doesn't seem feasible for now. |
I agree that we shouldn't try to fix this with more regexps; in the long run, we might consider using a GLP parser. Still, it may make sense to document the current restriction. |
Reopening as it looks like there's a viable solution after all. See GH-10125. |
This seems to break installs with I can't find in the GIT repo or mailing list history why the date/time parser (which we commit) couldn't deal with a later version. I think we should change the minimum in PHP to 1.0.3 (like the release images do) and I will also start using that for timelib's parser. I've made a PR to add that check: #10542 |
Description
The following code:
Resulted in this output:
But I expected this output instead:
PHP Version
PHP 8.1 and above, works fine in PHP 7.4
Operating System
No response
The text was updated successfully, but these errors were encountered: