From d0550b7a68d44551e3cae0aae5a6cf9180aec37e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 1 Aug 2019 16:18:22 +0200 Subject: [PATCH] Fix using array_key_exists() on objects, it is deprecated in PHP 7.4 --- src/Template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Template.php b/src/Template.php index 435f8c67e1..3f7447c126 100644 --- a/src/Template.php +++ b/src/Template.php @@ -537,7 +537,7 @@ protected function getAttribute($object, $item, array $arguments = [], $type = s if (self::METHOD_CALL !== $type) { $arrayItem = \is_bool($item) || \is_float($item) ? (int) $item : $item; - if (((\is_array($object) || $object instanceof \ArrayObject) && (isset($object[$arrayItem]) || \array_key_exists($arrayItem, $object))) + if (((\is_array($object) || $object instanceof \ArrayObject) && (isset($object[$arrayItem]) || \array_key_exists($arrayItem, (array) $object))) || ($object instanceof \ArrayAccess && isset($object[$arrayItem])) ) { if ($isDefinedTest) { @@ -604,7 +604,7 @@ protected function getAttribute($object, $item, array $arguments = [], $type = s // object property if (self::METHOD_CALL !== $type && !$object instanceof self) { // \Twig\Template does not have public properties, and we don't want to allow access to internal ones - if (isset($object->$item) || \array_key_exists((string) $item, $object)) { + if (isset($object->$item) || \array_key_exists((string) $item, (array) $object)) { if ($isDefinedTest) { return true; }