Merge branch '1.x' into 2.x

* 1.x:
  added more tests
  added missing hints in some runtime exceptions
This commit is contained in:
Fabien Potencier
2019-04-12 12:08:49 +02:00
16 changed files with 114 additions and 54 deletions
+4 -3
View File
@@ -35,16 +35,17 @@ class WithNode extends Node
$compiler->addDebugInfo($this);
if ($this->hasNode('variables')) {
$node = $this->getNode('variables');
$varsName = $compiler->getVarName();
$compiler
->write(sprintf('$%s = ', $varsName))
->subcompile($this->getNode('variables'))
->subcompile($node)
->raw(";\n")
->write(sprintf("if (!twig_test_iterable(\$%s)) {\n", $varsName))
->indent()
->write("throw new RuntimeError('Variables passed to the \"with\" tag must be a hash.', ")
->repr($this->getTemplateLine())
->raw(", \$this->source);\n")
->repr($node->getTemplateLine())
->raw(", \$this->getSourceContext());\n")
->outdent()
->write("}\n")
->write(sprintf("\$%s = twig_to_array(\$%s);\n", $varsName, $varsName))