28 if (!$alternatives = self::computeAlternatives(
$name, $items)) {
32 $this->
appendMessage(sprintf(
' Did you mean "%s"?', implode(
'", "', $alternatives)));
42 $alternatives =
array();
43 foreach ($items as $item) {
44 $lev = levenshtein(
$name, $item);
45 if ($lev <= strlen(
$name) / 3 ||
false !== strpos($item,
$name)) {
46 $alternatives[$item] = $lev;
51 return array_keys($alternatives);
55 class_alias(
'Twig_Error_Syntax',
'Twig\Error\SyntaxError',
false);
static computeAlternatives($name, $items)
addSuggestions($name, array $items)
Tweaks the error message to include suggestions.
Exception thrown when a syntax error occurs during lexing or parsing of a template.
appendMessage($rawMessage)
Create styles array
The data for the language used.