Created
July 22, 2013 08:40
-
-
Save predakanga/6052310 to your computer and use it in GitHub Desktop.
Twig context closure support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/twig/twig/lib/Twig/Template.php b/lib/twig/twig/lib/Twig/Template.php | |
| index a001ca0..1f3c04b 100644 | |
| --- a/lib/twig/twig/lib/Twig/Template.php | |
| +++ b/lib/twig/twig/lib/Twig/Template.php | |
| @@ -337,7 +337,7 @@ abstract class Twig_Template implements Twig_TemplateInterface | |
| protected function getAttribute($object, $item, array $arguments = array(), $type = Twig_TemplateInterface::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false) | |
| { | |
| // array | |
| - if (Twig_TemplateInterface::METHOD_CALL !== $type) { | |
| + if (!is_object($object)) { | |
| $arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item; | |
| if ((is_array($object) && array_key_exists($arrayItem, $object)) | |
| @@ -347,7 +347,11 @@ abstract class Twig_Template implements Twig_TemplateInterface | |
| return true; | |
| } | |
| - return $object[$arrayItem]; | |
| + if(Twig_TemplateInterface::METHOD_CALL === $type) { | |
| + return call_user_func_array($object[$arrayItem], $arguments); | |
| + } else { | |
| + return $object[$arrayItem]; | |
| + } | |
| } | |
| if (Twig_TemplateInterface::ARRAY_CALL === $type || !is_object($object)) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment