removed code that deal with potential null nodes (not possible anymore)

This commit is contained in:
Fabien Potencier
2016-09-24 11:26:50 -07:00
parent fc9dd3cad6
commit e50a84c78d
3 changed files with 4 additions and 14 deletions
+4 -6
View File
@@ -151,7 +151,7 @@ class Twig_Node implements Countable, IteratorAggregate
*/
public function hasNode($name)
{
return array_key_exists($name, $this->nodes);
return isset($this->nodes[$name]);
}
/**
@@ -163,7 +163,7 @@ class Twig_Node implements Countable, IteratorAggregate
*/
public function getNode($name)
{
if (!array_key_exists($name, $this->nodes)) {
if (!isset($this->nodes[$name])) {
throw new LogicException(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this)));
}
@@ -176,7 +176,7 @@ class Twig_Node implements Countable, IteratorAggregate
* @param string $name
* @param Twig_Node $node
*/
public function setNode($name, $node = null)
public function setNode($name, Twig_Node $node)
{
$this->nodes[$name] = $node;
}
@@ -205,9 +205,7 @@ class Twig_Node implements Countable, IteratorAggregate
{
$this->filename = $filename;
foreach ($this->nodes as $node) {
if (null !== $node) {
$node->setFilename($filename);
}
$node->setFilename($filename);
}
}
-4
View File
@@ -70,10 +70,6 @@ class Twig_NodeTraverser
private function traverseForVisitor(Twig_NodeVisitorInterface $visitor, Twig_Node $node = null)
{
if (null === $node) {
return;
}
$node = $visitor->enterNode($node, $this->env);
foreach ($node as $k => $n) {
@@ -89,10 +89,6 @@ class Twig_Tests_NodeVisitor_OptimizerTest extends PHPUnit_Framework_TestCase
public function checkForConfiguration(Twig_Node $node = null, $target, $withLoop)
{
if (null === $node) {
return;
}
foreach ($node as $n) {
if ($n instanceof Twig_Node_For) {
if ($target === $n->getNode('value_target')->getAttribute('name')) {