From: Fabien Potencier Date: Wed, 16 May 2012 14:18:48 +0000 (+0200) Subject: fixed a regression introduced by aa6b8358161e4ef35299be06a5ff61bfcba46f6a X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=8ec73cf4759f90b961de1732da1732e60c1dbfff;p=web%2Fkonrad%2Ftwig.git fixed a regression introduced by aa6b8358161e4ef35299be06a5ff61bfcba46f6a --- diff --git a/CHANGELOG b/CHANGELOG index 659cb71..b1a8ca0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ -* 1.9.0 (2012-XX-XX) +* 1.8.1 (2012-XX-XX) - * n/a + * fixed a regression when dealing with SimpleXMLElement instances in templates * 1.8.0 (2012-05-08) diff --git a/composer.json b/composer.json index d3d435b..9ca80fc 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.8-dev" } } } diff --git a/ext/twig/php_twig.h b/ext/twig/php_twig.h index ee6e9f2..ce2f65c 100644 --- a/ext/twig/php_twig.h +++ b/ext/twig/php_twig.h @@ -15,7 +15,7 @@ #ifndef PHP_TWIG_H #define PHP_TWIG_H -#define PHP_TWIG_VERSION "1.9.0-DEV" +#define PHP_TWIG_VERSION "1.8.1-DEV" #include "php.h" diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 1bdc64a..aaa3ece 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -17,7 +17,7 @@ */ class Twig_Environment { - const VERSION = '1.9.0-DEV'; + const VERSION = '1.8.1-DEV'; protected $charset; protected $loader; diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 6067ec0..1693596 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -326,7 +326,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) { - $item = (string) $item; + $item = is_numeric($item) ? (int) $item : (string) $item; // array if (Twig_TemplateInterface::METHOD_CALL !== $type) { diff --git a/test/Twig/Tests/Fixtures/regression/simple_xml_element.test b/test/Twig/Tests/Fixtures/regression/simple_xml_element.test new file mode 100644 index 0000000..6cb036b --- /dev/null +++ b/test/Twig/Tests/Fixtures/regression/simple_xml_element.test @@ -0,0 +1,15 @@ +--TEST-- +Twig is able to deal with SimpleXMLElement instances as variables +--TEMPLATE-- +Hello '{{ images.image.0.group }}'! +{{ images.children().count() }} +{% for image in images %} + - {{ image.group }} +{% endfor %} +--DATA-- +return array('images' => new SimpleXMLElement('foobar')) +--EXPECT-- +Hello 'foo'! +2 + - foo + - bar