Syntax.php in Translation template extractor 7.3
File
vendor/Twig/Error/Syntax.php
View source
<?php
class Twig_Error_Syntax extends Twig_Error {
public function addSuggestions($name, array $items) {
if (!($alternatives = self::computeAlternatives($name, $items))) {
return;
}
$this
->appendMessage(sprintf(' Did you mean "%s"?', implode('", "', $alternatives)));
}
public static function computeAlternatives($name, $items) {
$alternatives = array();
foreach ($items as $item) {
$lev = levenshtein($name, $item);
if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
$alternatives[$item] = $lev;
}
}
asort($alternatives);
return array_keys($alternatives);
}
}
Classes
Name |
Description |
Twig_Error_Syntax |
Exception thrown when a syntax error occurs during lexing or parsing of a template. |