Page MenuHomePhabricator

Add array method dereference support to xhpast.
ClosedPublic

Authored by Firehed on Mar 25 2014, 7:06 AM.
Tags
None
Referenced Files
F12861265: D8611.id20410.diff
Fri, Mar 29, 2:02 PM
Unknown Object (File)
Feb 28 2024, 3:37 PM
Unknown Object (File)
Feb 16 2024, 8:34 PM
Unknown Object (File)
Feb 16 2024, 8:14 PM
Unknown Object (File)
Feb 4 2024, 3:12 AM
Unknown Object (File)
Jan 29 2024, 1:28 PM
Unknown Object (File)
Jan 25 2024, 4:01 AM
Unknown Object (File)
Jan 15 2024, 1:06 PM
Subscribers

Details

Summary

Adds support for array method dereferencing, e.g. $foo->bar()[0]. Bumps XHPAST version. Ref T4334.

Test Plan

Wrote two failing unit tests for language parsing abilities using the specific errors mentioned in T4334. Hacked away at the parser importing bits from Zend's zend_language_parser.y until they passed.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Firehed retitled this revision from to Add array method dereference support to xhpast..
Firehed updated this object.
Firehed edited the test plan for this revision. (Show Details)
Firehed added a reviewer: epriestley.
This revision is now accepted and ready to land.Mar 25 2014, 7:22 PM

Oh, hrrm -- this generates an odd tree, I think. An input like $o->m()[0] generates something like:

n_METHOD_CALL
  n_THING_OR_SOMETHING
  n_INDEX_ACCESS
    n_CALL_PARAMETER_LIST
    n_OFFSET_OR_SOMETHING

Instead, I think it should generate this:

n_INDEX_ACCESS
  n_METHOD_CALL
    n_THING_OR_SOMETHING
    n_CALL_PARAMETER_LIST
  n_OFFSET_OR_SOMETHING

Let me see if I can move things around a little bit.

epriestley updated this revision to Diff 20410.

Closed by commit rPHU904d39effd20 (authored by @Firehed, committed by @epriestley).

We have some similar existing issues with $o->m[0][1] and fixing them is tricky. I'm going to make an attempt at it but not for the moment.

Ah, yes, that makes some amount of sense. I saw chaining_dereference: defined in the php parser that looked related, that's probably what it made work. That one gave me an unusually bad headache trying to decipher the zend states for some reason.