Currently the scanner eats whitespace after <?php but not after <?. This means that <?php tokenises to T_OPEN_TAG (see https://secure.phabricator.com/xhpast/view/853/) whereas <? tokenises to T_OPEN_TAG, T_WHITESPACE (see https://secure.phabricator.com/xhpast/view/854/).
Details
Details
- Reviewers
epriestley - Group Reviewers
Blessed Reviewers - Commits
- rPHUdc0626970a6d: Don't eat whitespace after T_OPEN_TAG
Before | After |
---|---|
Diff Detail
Diff Detail
- Repository
- rPHU libphutil
- Branch
- master
- Lint
Lint Passed - Unit
Tests Passed - Build Status
Buildable 7621 Build 8282: [Placeholder Plan] Wait for 30 Seconds Build 8280: arc lint + arc unit
Event Timeline
Comment Actions
Does this parse this input:
<?phpnot
...as containing a T_OPEN_TAG? It should not, since PHP will only recognize <?php as a T_OPEN_TAG if it is followed by whitespace.
Comment Actions
That is, with short_open_tag=1, this is a PHP script which prints "2":
<?echo 1+1;
While this is just a block of T_INLINE_HTML and prints the file content literally:
<?phpecho 1+1;
Comment Actions
Hmm, it looks like <?phpecho 1+1; is a syntax error according to the current XHPAST:
> echo '<?phpecho 1+1;' | ./support/xhpast/xhpast XHPAST Parse Error: syntax error, unexpected T_LNUMBER on line 1