You are here

class FunctionCallArgumentFilter in Drupal 7 to 8/9 Module Upgrader 8

Filters for function calls which are passed a particular argument.

Hierarchy

Expanded class hierarchy of FunctionCallArgumentFilter

2 files declare their use of FunctionCallArgumentFilter
ConverterBase.php in src/ConverterBase.php
FunctionCallArgumentFilterTest.php in tests/src/Unit/Utility/Filter/FunctionCallArgumentFilterTest.php

File

src/Utility/Filter/FunctionCallArgumentFilter.php, line 12

Namespace

Drupal\drupalmoduleupgrader\Utility\Filter
View source
class FunctionCallArgumentFilter {

  /**
   * @var string
   */
  protected $variable;
  public function __construct($variable) {
    $this->variable = $variable;
  }

  /**
   * @return bool
   */
  public function __invoke(Node $node) {
    if ($node instanceof FunctionCallNode) {
      return (bool) $node
        ->getArgumentList()
        ->children([
        $this,
        'hasArgument',
      ])
        ->count();
    }
    return FALSE;
  }

  /**
   * @return bool
   */
  public function hasArgument(Node $argument) {
    return $argument instanceof VariableNode && $argument
      ->getName() == $this->variable;
  }

}

Members