Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Converter / Functions / DrupalMapAssoc.php
1 <?php
2
3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
4
5 use Drupal\drupalmoduleupgrader\TargetInterface;
6 use Pharborist\Functions\FunctionCallNode;
7
8 /**
9  * @Converter(
10  *  id = "drupal_map_assoc",
11  *  description = @Translation("Rewrites calls to drupal_map_assoc().")
12  * )
13  */
14 class DrupalMapAssoc extends FunctionCallModifier {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function rewrite(FunctionCallNode $call, TargetInterface $target) {
20     // Change function name to array_combine().
21     $call->setName('array_combine');
22
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]);
28   }
29
30 }