Browse Source

Allow !replace to accept a scalar

This is the default merge behaviour, but simplifies using !replace because passing in a var that happens to evaluate to a scalar won't cause an issue anymore
master
Adam Pippin 3 years ago
parent
commit
706242074d
  1. 5
      app/Cfnpp/Functions.php

5
app/Cfnpp/Functions.php

@ -83,7 +83,10 @@ class Functions
*/
public function mf_replace(Node $original, Node $target, NodeFunction $function): ?Node
{
// TODO: Deal with nodefunctionvalue
if ($function instanceof NodeFunctionValue)
{
return new NodeValue(null, $target->hasName() ? $target->getName() : null, $function->getValue());
}
$replacement = new Node(null, $target->hasName() ? $target->getName() : null);
$replacement->setChildren($function->getChildren());

Loading…
Cancel
Save