fix storage of object properties in analysis
authorArnaud Le Blanc <arnaud.lb@gmail.com>
Sun, 7 Nov 2010 23:07:24 +0000 (00:07 +0100)
committerFabien Potencier <fabien.potencier@gmail.com>
Mon, 8 Nov 2010 06:48:13 +0000 (07:48 +0100)
lib/Twig/NodeVisitor/SafeAnalysis.php

index 0b89ec6..73b1037 100644 (file)
@@ -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)