Compare commits

...

3 Commits

  1. 14
      app/Cfnpp/Expression/Token/OperatorBinary.php
  2. 8
      app/Cfnpp/Functions.php

14
app/Cfnpp/Expression/Token/OperatorBinary.php

@ -102,18 +102,18 @@ class OperatorBinary extends TokenBinary implements ICloudformationNative
}
elseif (is_scalar($value1))
{
return $value1 ? $value2 : false;
return $value1 ? $arguments[1] : false;
}
elseif (is_scalar($value2))
{
return $value2 ? $value1 : false;
return $value2 ? $arguments[0] : false;
}
elseif ($value1 instanceof Parameter && $value2 instanceof Parameter && $value1->getName() == $value2->getName())
{
return $value1;
}
return null;
return null;
case 'or':
if (is_scalar($value1) && is_scalar($value2))
@ -122,18 +122,18 @@ class OperatorBinary extends TokenBinary implements ICloudformationNative
}
elseif (is_scalar($value1))
{
return $value1 ? true : $value1;
return $value1 ? true : $arguments[1];
}
elseif (is_scalar($value2))
{
return $value2 ? true : $value1;
return $value2 ? true : $arguments[0];
}
elseif ($value1 instanceof Parameter && $value2 instanceof Parameter && $value1->getName() == $value2->getName())
{
return $value1;
}
return null;
return null;
case 'eq':
if (is_scalar($value1) && is_scalar($value2))
@ -145,7 +145,7 @@ class OperatorBinary extends TokenBinary implements ICloudformationNative
return true;
}
return null;
return null;
default:
throw new \Exception('Missing implementation for unary operator: '.$this->getOperator());

8
app/Cfnpp/Functions.php

@ -195,10 +195,14 @@ class Functions
$n_orig = new Node(null, $node->hasName() ? $node->getName() : null);
$n_if = new Node($n_orig, 'Fn::If');
$n_orig->addChild($n_if);
$n_if->addChild(new NodeValue($n_if, null, $condition_name));
$n_if->addChild($if_true);
$n_if->addChild($if_false);
return $n_if;
if (isset($if_false))
{
$n_if->addChild($if_false);
}
return $n_orig;
}
/**

Loading…
Cancel
Save