protected $importedSymbols;
protected $traits;
protected $embeddedTemplates = array();
+ private $varNameSalt = 0;
public function __construct(Twig_Environment $env)
{
public function getVarName()
{
- return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
+ return sprintf('__internal_%s', hash('sha256', __METHOD__.$this->stream->getSourceContext()->getCode().$this->varNameSalt++));
}
/**
$this->blockStack = array();
$this->importedSymbols = array(array());
$this->embeddedTemplates = array();
+ $this->varNameSalt = 0;
try {
$body = $this->subparse($test, $dropNeedle);
$this->stream->next();
$token = $this->getCurrentToken();
- if ($token->getType() !== Twig_Token::NAME_TYPE) {
+ if (Twig_Token::NAME_TYPE !== $token->getType()) {
throw new Twig_Error_Syntax('A block must start with a tag name.', $token->getLine(), $this->stream->getSourceContext());
}
throw new Twig_Error_Syntax('A template that extends another one cannot start with a byte order mark (BOM); it must be removed.', $node->getTemplateLine(), $this->stream->getSourceContext());
}
- throw new Twig_Error_Syntax('A template that extends another one cannot include contents outside Twig blocks. Did you forget to put the contents inside a {% block %} tag?', $node->getTemplateLine(), $this->stream->getSourceContext());
+ throw new Twig_Error_Syntax('A template that extends another one cannot include content outside Twig blocks. Did you forget to put the content inside a {% block %} tag?', $node->getTemplateLine(), $this->stream->getSourceContext());
}
// bypass nodes that will "capture" the output
return $node;
}
}
+
+class_alias('Twig_Parser', 'Twig\Parser', false);
+class_exists('Twig_Node');
+class_exists('Twig_TokenStream');