From 62551da95e6d4aa3a34745a71d11b0d7a0942695 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Mon, 8 Nov 2010 00:07:24 +0100 Subject: [PATCH] fix storage of object properties in analysis --- lib/Twig/NodeVisitor/SafeAnalysis.php | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) 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) -- 1.7.2.5