grom358 / pharborist

A PHP library to query and transform source code via tree operations.
GNU General Public License v3.0
44 stars 10 forks source link

Add key manipulation methods to ArrayLookupNode #199

Open phenaproxima opened 9 years ago

phenaproxima commented 9 years ago

I'm in need of a few methods for manipulating the keys of an ArrayLookupNode:

Each of these methods should accept an ExpressionNode or a scalar value (which is converted with Node::fromValue).

I also need a setKey() method, to complement getKey(). setKey() should accept a numeric index and an ExpressionNode (or scalar value), and throw OutOfBoundsException if the key is an invalid index.

And finally, I need a setArray() method to complement getArray(). setArray() should accept an ExpressionNode only. The bugaboo here is that I'm not sure if I have to do something special if ExpressionNode is a function or method call, since that's technically an array deference. (Is there a specialized node type for that?)