mirror of
https://github.com/twigphp/Twig.git
synced 2026-11-11 21:06:21 +00:00
removed code that deal with potential null nodes (not possible anymore)
This commit is contained in:
+4
-6
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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')) {
|
||||
|
||||
Reference in New Issue
Block a user