mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 12:26:30 +00:00
Merge branch '2.x' into 3.x
* 2.x: Fix using array_key_exists() on objects, it is deprecated in PHP 7.4
This commit is contained in:
@@ -1354,7 +1354,7 @@ function twig_get_attribute(Environment $env, Source $source, $object, $item, ar
|
||||
if (/* Template::METHOD_CALL */ 'method' !== $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) {
|
||||
@@ -1425,7 +1425,7 @@ function twig_get_attribute(Environment $env, Source $source, $object, $item, ar
|
||||
|
||||
// object property
|
||||
if (/* Template::METHOD_CALL */ 'method' !== $type) {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user