3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
5 use Drupal\drupalmoduleupgrader\TargetInterface;
6 use Pharborist\Functions\FunctionCallNode;
7 use Pharborist\Types\StringNode;
10 * Parent class of the VariableGet, VariableSet, and VariableDel plugins.
12 abstract class VariableAPI extends FunctionCallModifier {
15 * Helper for subclasses' rewrite() methods. This checks if the call can
16 * be rewritten at all and leaves a FIXME if it can't. If the variable's
17 * key is not a string starting with MODULE_, the call will not be
18 * considered rewritable.
22 protected function tryRewrite(FunctionCallNode $call, TargetInterface $target) {
23 $statement = $call->getStatement();
24 $arguments = $call->getArguments();
26 if ($arguments[0] instanceof StringNode) {
27 $key = $arguments[0]->toValue();
29 if (strPos($key, $target->id() . '_') === 0) {
34 This looks like another module's variable. You'll need to rewrite this call
35 to ensure that it uses the correct configuration object.
37 $this->buildFixMe($comment)->prependTo($statement);
43 The correct configuration object could not be determined. You'll need to
44 rewrite this call manually.
46 $this->buildFixMe($comment)->prependTo($statement);