Adds support for array method dereferencing, e.g. $foo->bar()[0]. Bumps XHPAST version. Ref T4334.
Details
- Reviewers
epriestley - Group Reviewers
Blessed Reviewers - Maniphest Tasks
- T4334: Support PHP5.4+ syntax in XHPAST
- Commits
- rPHU904d39effd20: Add array method dereference support to xhpast.
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
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.
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.