You are here

public function ContainsLogicFilter::__invoke in Drupal 7 to 8/9 Module Upgrader 8

Tests if a function contains logic: any branching operator, function call, or object instantiation.

Parameters

\Pharborist\ParentNode $node: The node to test.

Return value

bool

File

src/Utility/Filter/ContainsLogicFilter.php, line 52

Class

ContainsLogicFilter

Namespace

Drupal\drupalmoduleupgrader\Utility\Filter

Code

public function __invoke(ParentNode $node) {
  $function_calls = $node
    ->find(Filter::isInstanceOf('\\Pharborist\\Functions\\FunctionCallNode'))
    ->not(function (FunctionCallNode $call) {
    return in_array($call
      ->getName()
      ->getText(), $this->whitelist);
  });
  if ($function_calls
    ->isEmpty()) {
    $filter = call_user_func_array('\\Pharborist\\Filter::isInstanceOf', static::$logic);
    return (bool) $node
      ->find($filter)
      ->count();
  }
  else {
    return TRUE;
  }
}