mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 09:44:55 +02:00
Update Twig to v2.15.4
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Twig;
|
||||
|
||||
use Twig\Node\Node;
|
||||
use Twig\NodeVisitor\NodeVisitorInterface;
|
||||
|
||||
/**
|
||||
@@ -18,14 +19,12 @@ use Twig\NodeVisitor\NodeVisitorInterface;
|
||||
*
|
||||
* It visits all nodes and their children and calls the given visitor for each.
|
||||
*
|
||||
* @final
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class NodeTraverser
|
||||
final class NodeTraverser
|
||||
{
|
||||
protected $env;
|
||||
protected $visitors = [];
|
||||
private $env;
|
||||
private $visitors = [];
|
||||
|
||||
/**
|
||||
* @param NodeVisitorInterface[] $visitors
|
||||
@@ -45,10 +44,8 @@ class NodeTraverser
|
||||
|
||||
/**
|
||||
* Traverses a node and calls the registered visitors.
|
||||
*
|
||||
* @return \Twig_NodeInterface
|
||||
*/
|
||||
public function traverse(\Twig_NodeInterface $node)
|
||||
public function traverse(Node $node): Node
|
||||
{
|
||||
ksort($this->visitors);
|
||||
foreach ($this->visitors as $visitors) {
|
||||
@@ -60,24 +57,23 @@ class NodeTraverser
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function traverseForVisitor(NodeVisitorInterface $visitor, \Twig_NodeInterface $node = null)
|
||||
/**
|
||||
* @return Node|null
|
||||
*/
|
||||
private function traverseForVisitor(NodeVisitorInterface $visitor, Node $node)
|
||||
{
|
||||
if (null === $node) {
|
||||
return;
|
||||
}
|
||||
|
||||
$node = $visitor->enterNode($node, $this->env);
|
||||
|
||||
foreach ($node as $k => $n) {
|
||||
if (null === $n) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false !== ($m = $this->traverseForVisitor($visitor, $n)) && null !== $m) {
|
||||
if ($m !== $n) {
|
||||
$node->setNode($k, $m);
|
||||
}
|
||||
} else {
|
||||
if (false === $m) {
|
||||
@trigger_error('Returning "false" to remove a Node from NodeVisitorInterface::leaveNode() is deprecated since Twig version 2.9; return "null" instead.', \E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$node->removeNode($k);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user