Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Analyzer / HookUninstall.php
1 <?php
2
3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer;
4
5 use Drupal\drupalmoduleupgrader\AnalyzerBase;
6 use Drupal\drupalmoduleupgrader\TargetInterface;
7 use Pharborist\Filter;
8 use Pharborist\Functions\FunctionCallNode;
9
10 /**
11  * @Analyzer(
12  *  id = "hook_uninstall",
13  *  description = @Translation("Removes variable_del() calls from hook_uninstall()."),
14  *  message = @Translation("Default configuration is deleted automatically."),
15  *  tags = {
16  *    "category" = { "config" },
17  *    "error_level" = "warning"
18  *  },
19  *  hook = "hook_uninstall"
20  * )
21  */
22 class HookUninstall extends AnalyzerBase {
23
24   /**
25    * {@inheritdoc}
26    */
27   public function analyze(TargetInterface $target) {
28     $indexer = $target->getIndexer('function');
29     $issues = [];
30
31     if ($indexer->has('hook_uninstall')) {
32       /** @var \Pharborist\NodeCollection $variable_del */
33       $variable_del = $indexer->get('hook_uninstall')->find(Filter::isFunctionCall('variable_del'));
34
35       if (sizeof($variable_del) > 0) {
36         $issue = $this->buildIssue($target);
37         $variable_del->each(function(FunctionCallNode $function_call) use ($issue) {
38           $issue->addViolation($function_call, $this);
39         });
40         $issues[] = $issue;
41       }
42     }
43
44     return $issues;
45   }
46
47 }