Merge branch '1.x' into 2.x

* 1.x:
  Ensure that syntax errors are triggered with the right line
  fix a typo
This commit is contained in:
Fabien Potencier
2018-06-07 07:41:23 +02:00
3 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -311,7 +311,7 @@ will be available in the included template too:
The included template ``render_box.html`` is able to access the ``box`` variable.
The filename of the template depends on the template loader. For instance, the
The name of the template depends on the template loader. For instance, the
``Twig_Loader_Filesystem`` allows you to access other templates by giving the
filename. You can access templates in subdirectories with a slash:
+6 -6
View File
@@ -112,7 +112,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
$named = true;
$name = $this->normalizeName($name);
} elseif ($named) {
throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $callType, $callName));
throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $callType, $callName), $this->getTemplateLine());
}
$parameters[$name] = $node;
@@ -144,14 +144,14 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
if (array_key_exists($name, $parameters)) {
if (array_key_exists($pos, $parameters)) {
throw new Twig_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $callType, $callName));
throw new Twig_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $callType, $callName), $this->getTemplateLine());
}
if (count($missingArguments)) {
throw new Twig_Error_Syntax(sprintf(
'Argument "%s" could not be assigned for %s "%s(%s)" because it is mapped to an internal PHP function which cannot determine default value for optional argument%s "%s".',
$name, $callType, $callName, implode(', ', $names), count($missingArguments) > 1 ? 's' : '', implode('", "', $missingArguments))
);
$name, $callType, $callName, implode(', ', $names), count($missingArguments) > 1 ? 's' : '', implode('", "', $missingArguments)
), $this->getTemplateLine());
}
$arguments = array_merge($arguments, $optionalArguments);
@@ -173,7 +173,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
$missingArguments[] = $name;
}
} else {
throw new Twig_Error_Syntax(sprintf('Value for argument "%s" is required for %s "%s".', $name, $callType, $callName));
throw new Twig_Error_Syntax(sprintf('Value for argument "%s" is required for %s "%s".', $name, $callType, $callName), $this->getTemplateLine());
}
}
@@ -206,7 +206,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
throw new Twig_Error_Syntax(sprintf(
'Unknown argument%s "%s" for %s "%s(%s)".',
count($parameters) > 1 ? 's' : '', implode('", "', array_keys($parameters)), $callType, $callName, implode(', ', $names)
), $unknownParameter ? $unknownParameter->getTemplateLine() : -1);
), $unknownParameter ? $unknownParameter->getTemplateLine() : $this->getTemplateLine());
}
return $arguments;
@@ -112,7 +112,7 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase
/**
* @expectedException Twig_Error_Syntax
* @expectedExceptionMessage Value for argument "from" is required for filter "replace".
* @expectedExceptionMessage Value for argument "from" is required for filter "replace" at line 1.
*/
public function testCompileWithMissingNamedArgument()
{