allowed Twig\NodeVisitor\NodeVisitorInterface::leaveNode() to return "null" instead of "false" (same meaning)

This commit is contained in:
Fabien Potencier
2019-04-25 10:42:32 +02:00
parent eed9c5fb87
commit f297b52f36
4 changed files with 6 additions and 3 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.40.0 (2019-XX-XX)
* allowed Twig\NodeVisitor\NodeVisitorInterface::leaveNode() to return "null" instead of "false" (same meaning)
* added the "apply" tag as a replacement for the "filter" tag
* allowed Twig\Loader\FilesystemLoader::findTemplate() to return "null" instead of "false" (same meaning)
* added support for "Twig\Markup" instances in the "in" test
+1 -1
View File
@@ -69,7 +69,7 @@ class NodeTraverser
$node = $visitor->enterNode($node, $this->env);
foreach ($node as $k => $n) {
if (false !== $m = $this->traverseForVisitor($visitor, $n)) {
if (false !== ($m = $this->traverseForVisitor($visitor, $n)) && null !== $m) {
if ($m !== $n) {
$node->setNode($k, $m);
}
+3 -1
View File
@@ -17,6 +17,8 @@ use Twig\Node\Node;
/**
* Used to make node visitors compatible with Twig 1.x and 2.x.
*
* To be removed in Twig 3.1.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
abstract class AbstractNodeVisitor implements NodeVisitorInterface
@@ -49,7 +51,7 @@ abstract class AbstractNodeVisitor implements NodeVisitorInterface
/**
* Called after child nodes are visited.
*
* @return Node|false The modified node or false if the node must be removed
* @return Node|false|null The modified node or null if the node must be removed
*/
abstract protected function doLeaveNode(Node $node, Environment $env);
}
+1 -1
View File
@@ -30,7 +30,7 @@ interface NodeVisitorInterface
/**
* Called after child nodes are visited.
*
* @return \Twig_NodeInterface|false The modified node or false if the node must be removed
* @return \Twig_NodeInterface|false|null The modified node or null if the node must be removed
*/
public function leaveNode(\Twig_NodeInterface $node, Environment $env);