From: Fabien Potencier Date: Sat, 12 Jun 2010 11:01:26 +0000 (+0200) Subject: fixed getContext() and getAttribute() when a property value exist but is null (closes... X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=cc37d83b216a919910d55a67b460768a4c9a2d77;p=web%2Fkonrad%2Ftwig.git fixed getContext() and getAttribute() when a property value exist but is null (closes #67) --- 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); }