3 namespace Drupal\drupalmoduleupgrader\Utility\Filter;
5 use Pharborist\ArrayLookupNode;
7 use Pharborist\Objects\ObjectPropertyNode;
8 use Pharborist\Variables\VariableNode;
11 * Filters for things that *look like* field accesses, e.g.
12 * $foo->bar[LANGUAGE_NONE][0]['value']. This filter doesn't guarantee that
13 * matched nodes actually ARE field accesses -- just that they have the proper
14 * formation (S-foils in attack formation!...what, you don't like Star Wars?)
16 class FieldValueFilter {
23 public function __construct($variable) {
24 $this->variable = $variable;
30 public function __invoke(Node $node) {
31 if ($node instanceof ArrayLookupNode) {
32 $root = $node->getRootArray();
34 if ($root instanceof ObjectPropertyNode) {
35 $object = $root->getObject();
37 if ($object instanceof VariableNode && $object->getName() == $this->variable) {
38 return (sizeof($node->getKeys()) >= 3);