Page MenuHomePhabricator

Add coalesce and spaceship operators to xhpast
ClosedPublic

Authored by richardvanvelzen on May 6 2016, 10:05 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 7:34 PM
Unknown Object (File)
Mon, Nov 18, 4:07 PM
Unknown Object (File)
Mon, Nov 18, 4:07 PM
Unknown Object (File)
Mon, Nov 18, 12:45 PM
Unknown Object (File)
Mon, Nov 18, 12:40 PM
Unknown Object (File)
Mon, Nov 18, 11:16 AM
Unknown Object (File)
Sat, Nov 16, 12:27 PM
Unknown Object (File)
Tue, Nov 12, 3:51 PM
Subscribers

Details

Summary
  • $value ?? $other is roughtly translates to isset($value) ? $value : $other
  • $a <=> $b translates to ($a < $b) ? -1 : (($a > $b) ? 1 : 0).

Because these new tokens appear in-between other tokens, a lot of token values were updated. All test cases have been updated to have the correct token values.

Test Plan

Fully rebuild xhpast, run all parser tests.

Diff Detail

Repository
rPHU libphutil
Branch
xhpast-coalesce
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 12078
Build 15217: arc lint + arc unit

Event Timeline

richardvanvelzen retitled this revision from to Add coalesce and spaceship operators to xhpast.
richardvanvelzen updated this object.
richardvanvelzen edited the test plan for this revision. (Show Details)
richardvanvelzen added a reviewer: epriestley.

On a sidenote, arc unit --everything in arcanist seems totally okay with these changes as well.

src/parser/xhpast/parser_tokens.php
5

I copied / adapted this list from YYTOKENTYPE in parser.yacc.cpp. It seemed a bit out-of date.

richardvanvelzen edited edge metadata.

Remove useless %token declaration for T_COALESCE

This is starting to bite us now - especially the coalesce construct is so useful that people started using it, taking lint syntax errors for granted.

If there's anything in particular I can change here to make reviewing it more bearable please let me know.

epriestley edited edge metadata.

I vaguely imagined fixing the unit test format to be human-readable while you were away for the weekend, but obviously did not.

This revision is now accepted and ready to land.May 18 2016, 4:58 PM
This revision was automatically updated to reflect the committed changes.