Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Update Twig library to 1.28.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Florens Verschelde committed Dec 6, 2016
1 parent 8b8bb09 commit 488198c
Show file tree
Hide file tree
Showing 78 changed files with 1,504 additions and 693 deletions.
43 changes: 43 additions & 0 deletions lib/Twig/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
* 1.28.2 (2016-11-23)

* fixed precedence between getFoo() and isFoo() in Twig_Template::getAttribute()
* improved a deprecation message

* 1.28.1 (2016-11-18)

* fixed block() function when used with a template argument

* 1.28.0 (2016-11-17)

* added support for the PHP 7 null coalescing operator for the ?? Twig implementation
* exposed a way to access template data and methods in a portable way
* changed context access to use the PHP 7 null coalescing operator when available
* added the "with" tag
* added support for a custom template on the block() function
* added "is defined" support for block() and constant()
* optimized the way attributes are fetched

* 1.27.0 (2016-10-25)

* deprecated Twig_Parser::getEnvironment()
* deprecated Twig_Parser::addHandler() and Twig_Parser::addNodeVisitor()
* deprecated Twig_Compiler::addIndentation()
* fixed regression when registering two extensions having the same class name
* deprecated Twig_LoaderInterface::getSource() (implement Twig_SourceContextLoaderInterface instead)
* fixed the filesystem loader with relative paths
* deprecated Twig_Node::getLine() in favor of Twig_Node::getTemplateLine()
* deprecated Twig_Template::getSource() in favor of Twig_Template::getSourceContext()
* deprecated Twig_Node::getFilename() in favor of Twig_Node::getTemplateName()
* deprecated the "filename" escaping strategy (use "name" instead)
* added Twig_Source to hold information about the original template
* deprecated Twig_Error::getTemplateFile() and Twig_Error::setTemplateFile() in favor of Twig_Error::getTemplateName() and Twig_Error::setTemplateName()
* deprecated Parser::getFilename()
* fixed template paths when a template name contains a protocol like vfs://
* improved debugging with Twig_Sandbox_SecurityError exceptions for disallowed methods and properties

* 1.26.1 (2016-10-05)

* removed template source code from generated template classes when debug is disabled
* fixed default implementation of Twig_Template::getDebugInfo() for better BC
* fixed regression on static calls for functions/filters/tests

* 1.26.0 (2016-10-02)

* added template cache invalidation based on more environment options
Expand Down
6 changes: 0 additions & 6 deletions lib/Twig/lib/Twig/BaseNodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,13 @@ final public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
/**
* Called before child nodes are visited.
*
* @param Twig_Node $node The node to visit
* @param Twig_Environment $env The Twig environment instance
*
* @return Twig_Node The modified node
*/
abstract protected function doEnterNode(Twig_Node $node, Twig_Environment $env);

/**
* Called after child nodes are visited.
*
* @param Twig_Node $node The node to visit
* @param Twig_Environment $env The Twig environment instance
*
* @return Twig_Node|false The modified node or false if the node must be removed
*/
abstract protected function doLeaveNode(Twig_Node $node, Twig_Environment $env);
Expand Down
48 changes: 21 additions & 27 deletions lib/Twig/lib/Twig/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ class Twig_Compiler implements Twig_CompilerInterface
protected $sourceLine;
protected $filename;

/**
* Constructor.
*
* @param Twig_Environment $env The twig environment instance
*/
public function __construct(Twig_Environment $env)
{
$this->env = $env;
Expand All @@ -49,7 +44,7 @@ public function getFilename()
/**
* Returns the environment instance related to this compiler.
*
* @return Twig_Environment The environment instance
* @return Twig_Environment
*/
public function getEnvironment()
{
Expand All @@ -72,7 +67,7 @@ public function getSource()
* @param Twig_NodeInterface $node The node to compile
* @param int $indentation The current indentation
*
* @return Twig_Compiler The current compiler instance
* @return $this
*/
public function compile(Twig_NodeInterface $node, $indentation = 0)
{
Expand All @@ -85,10 +80,8 @@ public function compile(Twig_NodeInterface $node, $indentation = 0)
$this->indentation = $indentation;

if ($node instanceof Twig_Node_Module) {
$node->setFilename($node->getAttribute('filename'));

// to be removed in 2.0
$this->filename = $node->getAttribute('filename');
$this->filename = $node->getTemplateName();
}

$node->compile($this);
Expand All @@ -99,7 +92,7 @@ public function compile(Twig_NodeInterface $node, $indentation = 0)
public function subcompile(Twig_NodeInterface $node, $raw = true)
{
if (false === $raw) {
$this->addIndentation();
$this->source .= str_repeat(' ', $this->indentation * 4);
}

$node->compile($this);
Expand All @@ -112,7 +105,7 @@ public function subcompile(Twig_NodeInterface $node, $raw = true)
*
* @param string $string The string
*
* @return Twig_Compiler The current compiler instance
* @return $this
*/
public function raw($string)
{
Expand All @@ -124,14 +117,13 @@ public function raw($string)
/**
* Writes a string to the compiled code by adding indentation.
*
* @return Twig_Compiler The current compiler instance
* @return $this
*/
public function write()
{
$strings = func_get_args();
foreach ($strings as $string) {
$this->addIndentation();
$this->source .= $string;
$this->source .= str_repeat(' ', $this->indentation * 4).$string;
}

return $this;
Expand All @@ -140,10 +132,14 @@ public function write()
/**
* Appends an indentation to the current PHP code after compilation.
*
* @return Twig_Compiler The current compiler instance
* @return $this
*
* @deprecated since 1.27 (to be removed in 2.0).
*/
public function addIndentation()
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use write(\'\') instead.', E_USER_DEPRECATED);

$this->source .= str_repeat(' ', $this->indentation * 4);

return $this;
Expand All @@ -154,7 +150,7 @@ public function addIndentation()
*
* @param string $value The string
*
* @return Twig_Compiler The current compiler instance
* @return $this
*/
public function string($value)
{
Expand All @@ -168,7 +164,7 @@ public function string($value)
*
* @param mixed $value The value to convert
*
* @return Twig_Compiler The current compiler instance
* @return $this
*/
public function repr($value)
{
Expand Down Expand Up @@ -209,14 +205,12 @@ public function repr($value)
/**
* Adds debugging information.
*
* @param Twig_NodeInterface $node The related twig node
*
* @return Twig_Compiler The current compiler instance
* @return $this
*/
public function addDebugInfo(Twig_NodeInterface $node)
{
if ($node->getLine() != $this->lastLine) {
$this->write(sprintf("// line %d\n", $node->getLine()));
if ($node->getTemplateLine() != $this->lastLine) {
$this->write(sprintf("// line %d\n", $node->getTemplateLine()));

// when mbstring.func_overload is set to 2
// mb_substr_count() replaces substr_count()
Expand All @@ -228,9 +222,9 @@ public function addDebugInfo(Twig_NodeInterface $node)
$this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset);
}
$this->sourceOffset = strlen($this->source);
$this->debugInfo[$this->sourceLine] = $node->getLine();
$this->debugInfo[$this->sourceLine] = $node->getTemplateLine();

$this->lastLine = $node->getLine();
$this->lastLine = $node->getTemplateLine();
}

return $this;
Expand All @@ -248,7 +242,7 @@ public function getDebugInfo()
*
* @param int $step The number of indentation to add
*
* @return Twig_Compiler The current compiler instance
* @return $this
*/
public function indent($step = 1)
{
Expand All @@ -262,7 +256,7 @@ public function indent($step = 1)
*
* @param int $step The number of indentation to remove
*
* @return Twig_Compiler The current compiler instance
* @return $this
*
* @throws LogicException When trying to outdent too much so the indentation would become negative
*/
Expand Down
4 changes: 1 addition & 3 deletions lib/Twig/lib/Twig/CompilerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ interface Twig_CompilerInterface
/**
* Compiles a node.
*
* @param Twig_NodeInterface $node The node to compile
*
* @return Twig_CompilerInterface The current compiler instance
* @return $this
*/
public function compile(Twig_NodeInterface $node);

Expand Down
Loading

0 comments on commit 488198c

Please sign in to comment.