Browse files

- fix property access when the instance implements Iterator or simila…

…r cases, by using get_object_vars instead, thx Arnaud Leblanc for the hint.
  • Loading branch information...
1 parent 7bc07dc commit 115edf2a71560a95aff11ef428e05cb21a286345 @pierrejoye pierrejoye committed Nov 21, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/Twig/Template.php
View
6 lib/Twig/Template.php
@@ -357,9 +357,11 @@ protected function getAttribute($object, $item, array $arguments = array(), $typ
// object property
if (Twig_TemplateInterface::METHOD_CALL !== $type) {
if (!isset(self::$cache[$class]['properties'])) {
- foreach ($object as $k => $v) {
- self::$cache[$class]['properties'][$k] = true;
+ $props = get_object_vars($object);
+ foreach ($props as &$v) {
+ $v = true;
}
+ self::$cache[$class]['properties'] = $props;
}
if (isset(self::$cache[$class]['properties'][$item])

0 comments on commit 115edf2

Please sign in to comment.