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)
Sun, Mar 17, 7:31 PM
Unknown Object (File)
Sun, Mar 17, 7:23 PM
Unknown Object (File)
Sun, Mar 17, 7:14 PM
Unknown Object (File)
Sun, Mar 17, 7:11 PM
Unknown Object (File)
Sun, Mar 17, 6:44 PM
Unknown Object (File)
Sun, Mar 17, 5:57 PM
Unknown Object (File)
Sun, Mar 17, 5:39 PM
Unknown Object (File)
Fri, Mar 15, 7:21 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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.