-
Notifications
You must be signed in to change notification settings - Fork 79
Fix handling of HaltCompilerStatement #389
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
Conversation
63bf6cc
to
508ae7b
Compare
Make it easier to calculate `__COMPILER_HALT_OFFSET__`. Related to microsoft#381 Address other edge cases
508ae7b
to
9143577
Compare
This is ready for review. The ParserInvariantTest asserts that the tokens combine into the original file for the test cases of |
All properties should be MissingTokens and non-null
Include whitespace before the data as part of the data for invalid ASTs.
3dceed7
to
d9e3877
Compare
One last change: A real InlineHtml node would have no leading whitespace/comments, so make fullStart = start.
|
}, | ||
{ | ||
"error": "SkippedToken", | ||
"kind": "ColonColonToken", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasoning in updating the tests I'd added in the previous PR is that HaltCompiler should halt the compiler and not parse any more statements, so I'd treat the snippet like __halt_compiler[();]::foo();
with inline html of ::foo();\n
(this token can't be used in other statements/expressions and is a syntax error)
<?php
// invalid
__halt_compiler::foo();
The MissingToken in the original tree were due to token_get_all() returning at most 3 tokens after T_HALT_COMPILER then returning T_INLINE_HTML for the rest
Make it easier to calculate
__COMPILER_HALT_OFFSET__
and make properties other thandata
non-null.Combine all tokens after halt compiler statement into an InlineHtml token that goes into HaltCompilerStatement->data if there are bytes.
Related to #381