3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
5 use Drupal\drupalmoduleupgrader\TargetInterface;
6 use Pharborist\Functions\FunctionCallNode;
10 * id = "drupal_map_assoc",
11 * description = @Translation("Rewrites calls to drupal_map_assoc().")
14 class DrupalMapAssoc extends FunctionCallModifier {
19 public function rewrite(FunctionCallNode $call, TargetInterface $target) {
20 // Change function name to array_combine().
21 $call->setName('array_combine');
23 // Duplicate the first $array argument twice (silly, but true).
24 // Need to clone the argument to make a copy of it, since Pharborist works
25 // on original tree elements.
26 $arguments = $call->getArguments();
27 return $call->appendArgument(clone $arguments[0]);