You are here

public function HookUninstall::analyze in Drupal 7 to 8/9 Module Upgrader 8

Analyzes a target module and flags any issues found.

Parameters

TargetInterface $target: The target module.

Return value

\Drupal\drupalmoduleupgrader\IssueInterface[]

Overrides AnalyzerInterface::analyze

File

src/Plugin/DMU/Analyzer/HookUninstall.php, line 27

Class

HookUninstall
Plugin annotation @Analyzer( id = "hook_uninstall", description = @Translation("Removes variable_del() calls from hook_uninstall()."), message = @Translation("Default configuration is deleted automatically."), tags = { "category" = { "config"…

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer

Code

public function analyze(TargetInterface $target) {
  $indexer = $target
    ->getIndexer('function');
  $issues = [];
  if ($indexer
    ->has('hook_uninstall')) {

    /** @var \Pharborist\NodeCollection $variable_del */
    $variable_del = $indexer
      ->get('hook_uninstall')
      ->find(Filter::isFunctionCall('variable_del'));
    if (sizeof($variable_del) > 0) {
      $issue = $this
        ->buildIssue($target);
      $variable_del
        ->each(function (FunctionCallNode $function_call) use ($issue) {
        $issue
          ->addViolation($function_call, $this);
      });
      $issues[] = $issue;
    }
  }
  return $issues;
}