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)
Fri, Apr 26, 3:06 AM
Unknown Object (File)
Fri, Apr 26, 3:06 AM
Unknown Object (File)
Fri, Apr 26, 3:06 AM
Unknown Object (File)
Fri, Apr 26, 3:06 AM
Unknown Object (File)
Thu, Apr 25, 2:25 AM
Unknown Object (File)
Wed, Apr 24, 3:39 AM
Unknown Object (File)
Fri, Apr 19, 2:28 AM
Unknown Object (File)
Fri, Apr 19, 2:28 AM
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 12077
Build 15216: 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.