Skip to content

Commit

Permalink
Fix using array_key_exists() on objects, it is deprecated in PHP 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Aug 1, 2019
1 parent ef4ae44 commit d0550b7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Template.php
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit d0550b7

Please sign in to comment.