From 64e856892ba3eebe927f334fa6f53858992b9a31 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 Mar 2018 09:45:57 -0800 Subject: [PATCH 1/3] fixed Travis config --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index d46869a72..56c6d0955 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,5 +52,7 @@ matrix: env: TWIG_EXT=yes - php: 7.1 env: TWIG_EXT=yes + - php: 7.2 + env: TWIG_EXT=yes - php: nightly env: TWIG_EXT=yes From a0c24242de21b50c5e1003c0469e9286a8594a01 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 Mar 2018 09:40:18 -0800 Subject: [PATCH 2/3] fixed C ext --- ext/twig/twig.c | 8 +++++++- lib/Twig/Template.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/twig/twig.c b/ext/twig/twig.c index 6173c0067..1304a144a 100644 --- a/ext/twig/twig.c +++ b/ext/twig/twig.c @@ -870,6 +870,8 @@ PHP_FUNCTION(twig_template_get_attributes) if (null === $object) { $message = sprintf('Impossible to invoke a method ("%s") on a null variable', $item); + } elseif (is_array($object)) { + $message = sprintf('Impossible to invoke a method ("%s") on an array.', $item); } else { $message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s")', $item, gettype($object), $object); } @@ -887,7 +889,11 @@ PHP_FUNCTION(twig_template_get_attributes) if (Z_TYPE_P(object) == IS_NULL) { convert_to_string_ex(&object); - TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on a %s variable.", item, type_name); + TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on a null variable.", item); + } else if (Z_TYPE_P(object) == IS_ARRAY) { + convert_to_string_ex(&object); + + TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on an array.", item); } else { convert_to_string_ex(&object); diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 1275c131e..2042c6bcf 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -569,7 +569,7 @@ abstract class Twig_Template implements Twig_TemplateInterface if (null === $object) { $message = sprintf('Impossible to invoke a method ("%s") on a null variable.', $item); } elseif (is_array($object)) { - $message = sprintf('Impossible to invoke a method ("%s") on an array.', $item); + $message = sprintf('Impossible to invoke a method ("%s") on an array.', $item); } else { $message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s").', $item, gettype($object), $object); } From bffc117f532963961ab393af440e9bd4b00c6ca7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 Mar 2018 09:54:18 -0800 Subject: [PATCH 3/3] simplified code --- ext/twig/twig.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ext/twig/twig.c b/ext/twig/twig.c index 1304a144a..b81d8ce3c 100644 --- a/ext/twig/twig.c +++ b/ext/twig/twig.c @@ -887,12 +887,8 @@ PHP_FUNCTION(twig_template_get_attributes) type_name = zend_zval_type_name(object); Z_ADDREF_P(object); if (Z_TYPE_P(object) == IS_NULL) { - convert_to_string_ex(&object); - TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on a null variable.", item); } else if (Z_TYPE_P(object) == IS_ARRAY) { - convert_to_string_ex(&object); - TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on an array.", item); } else { convert_to_string_ex(&object);