Browse Source

Cleanup

master
Adam Pippin 3 years ago
parent
commit
326e856a2b
  1. 2
      app/Cfnpp/Compiler.php
  2. 11
      app/Cfnpp/Expression/Expression.php

2
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());
}
}

11
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();

Loading…
Cancel
Save