From cc37d83b216a919910d55a67b460768a4c9a2d77 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 12 Jun 2010 13:01:26 +0200 Subject: [PATCH] fixed getContext() and getAttribute() when a property value exist but is null (closes #67) --- lib/Twig/Resource.php | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Twig/Resource.php b/lib/Twig/Resource.php index 0386a0b..ee064a3 100644 --- a/lib/Twig/Resource.php +++ b/lib/Twig/Resource.php @@ -26,7 +26,7 @@ abstract class Twig_Resource protected function getContext($context, $item) { - if (isset($context[$item])) { + if (array_key_exists($item, $context)) { return $context[$item]; } @@ -34,7 +34,7 @@ abstract class Twig_Resource return null; } - throw new InvalidArgumentException(sprintf('Item "%s" from context does not exist.', $item)); + throw new InvalidArgumentException(sprintf('Variable "%s" does not exist.', $item)); } protected function getAttribute($object, $item, array $arguments = array(), $type = Twig_Node_Expression_GetAttr::TYPE_ANY) @@ -64,7 +64,7 @@ abstract class Twig_Resource // object property if (Twig_Node_Expression_GetAttr::TYPE_METHOD !== $type) { - if (isset($object->$item)) { + if (property_exists($object, $item)) { if ($this->env->hasExtension('sandbox')) { $this->env->getExtension('sandbox')->checkPropertyAllowed($object, $item); } -- 1.7.2.5