From 706242074dd4a6c8ba418c10135299d010f1b16d Mon Sep 17 00:00:00 2001 From: Adam Pippin Date: Thu, 18 Feb 2021 11:48:10 -0800 Subject: [PATCH] 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 --- app/Cfnpp/Functions.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Cfnpp/Functions.php b/app/Cfnpp/Functions.php index 29131a8..6321ce1 100644 --- a/app/Cfnpp/Functions.php +++ b/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());