From 326e856a2b76b1f05b65b7163366422b82c3acec Mon Sep 17 00:00:00 2001 From: Adam Pippin Date: Sun, 21 Feb 2021 18:41:00 -0800 Subject: [PATCH] Cleanup --- app/Cfnpp/Compiler.php | 2 +- app/Cfnpp/Expression/Expression.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Cfnpp/Compiler.php b/app/Cfnpp/Compiler.php index 051c593..b46c8b3 100644 --- a/app/Cfnpp/Compiler.php +++ b/app/Cfnpp/Compiler.php @@ -296,7 +296,7 @@ class Compiler implements \App\Engine\ICompile elseif ($node instanceof NodeFunctionValue && $node->getName() == 'expr') { - $expression = new \App\Cfnpp\Expression\Expression($node->getValue(), $options); + $expression = new \App\Cfnpp\Expression\Expression($node->getValue()); $variables = array_merge($variables, $expression->getReferencedVariables()); } } diff --git a/app/Cfnpp/Expression/Expression.php b/app/Cfnpp/Expression/Expression.php index 81ba21d..5d35e5e 100644 --- a/app/Cfnpp/Expression/Expression.php +++ b/app/Cfnpp/Expression/Expression.php @@ -46,7 +46,6 @@ class Expression * Expression is tokenized, parsed, and solved on creation. * * @param string $expression - * @param \App\Engine\IOptions $options */ public function __construct(string $expression) { @@ -54,7 +53,13 @@ class Expression $this->nodes = static::parse($tokens); } - public function solve(\App\Engine\IOptions $options) + /** + * Solve this expression down to the minimal set of nodes we can + * + * @param \App\Engine\IOptions $options + * @return void + */ + public function solve(\App\Engine\IOptions $options): void { $this->nodes = static::_solve($this->nodes, $options->getVariables(), array_keys($options->getParameters())); } @@ -142,7 +147,7 @@ class Expression $variables = []; foreach ($this->nodes as $node) { - $node->walk(function($node) use (&$variables) { + $node->walk(function(GraphNode $node) use (&$variables): void { if ($node->getValue() instanceof Token\Variable) { $variables[] = $node->getValue()->getName();