From: Arnaud Le Blanc Date: Sun, 7 Nov 2010 23:07:24 +0000 (+0100) Subject: fix storage of object properties in analysis X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=62551da95e6d4aa3a34745a71d11b0d7a0942695;p=web%2Fkonrad%2Ftwig.git fix storage of object properties in analysis --- diff --git a/lib/Twig/NodeVisitor/SafeAnalysis.php b/lib/Twig/NodeVisitor/SafeAnalysis.php index 0b89ec6..73b1037 100644 --- a/lib/Twig/NodeVisitor/SafeAnalysis.php +++ b/lib/Twig/NodeVisitor/SafeAnalysis.php @@ -2,19 +2,21 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface { - protected $data = array(); + protected $data; - public function getSafe(Twig_NodeInterface $node) + public function __construct() { - $hash = spl_object_hash($node); + $this->data = new SplObjectStorage(); + } - return isset($this->data[$hash]) ? $this->data[$hash] : null; + public function getSafe(Twig_NodeInterface $node) + { + return isset($this->data[$node]) ? $this->data[$node] : null; } protected function setSafe(Twig_NodeInterface $node, array $safe) { - $hash = spl_object_hash($node); - $this->data[$hash] = $safe; + $this->data[$node] = $safe; } public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)