You are here

NodeAssignmentFilter.php in Drupal 7 to 8/9 Module Upgrader 8

File

src/Utility/Filter/NodeAssignmentFilter.php
View source
<?php

namespace Drupal\drupalmoduleupgrader\Utility\Filter;

use Pharborist\Filter;
use Pharborist\Node;
class NodeAssignmentFilter {

  /**
   * Tests if the given node is on the left side of an assignment.
   *
   * @param \Pharborist\Node $node
   *   The node to test.
   *
   * @return bool
   */
  public function __invoke(Node $node) {

    /** @var \Pharborist\Operators\AssignNode $assignment */
    $assignment = $node
      ->closest(Filter::isInstanceOf('\\Pharborist\\Operators\\AssignNode'));
    return $assignment ? $assignment
      ->getLeftOperand() === $node : FALSE;
  }

}

Classes