3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer;
5 use Drupal\drupalmoduleupgrader\AnalyzerBase;
6 use Drupal\drupalmoduleupgrader\TargetInterface;
7 use Pharborist\Functions\FunctionCallNode;
8 use Pharborist\Types\StringNode;
13 * message = @Translation("Certain database tables have been removed."),
15 * "category" = { "db" }
17 * deriver = "\Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer\DBDeriver"
20 class DB extends AnalyzerBase {
23 * Tables which will cause the function call to be commented out.
27 protected static $forbiddenTables = ['variable'];
32 public function analyze(TargetInterface $target) {
33 $function_calls = $target
34 ->getIndexer('function_call')
35 ->get($this->pluginDefinition['function'] ?: $this->getPluginId())
36 ->filter(function(FunctionCallNode $function_call) {
37 $arguments = $function_call->getArguments();
38 return $arguments[0] instanceof StringNode && in_array($arguments[0]->toValue(), self::$forbiddenTables);
42 if ($function_calls->count() > 0) {
43 $issue = $this->buildIssue($target);
44 $function_calls->each(function(FunctionCallNode $function_call) use ($issue) {
45 $issue->addViolation($function_call, $this);