mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 12:06:56 +00:00
Fix wrong array index
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# 3.20.0 (2025-XX-XX)
|
||||
|
||||
* Fix wrong array index
|
||||
* Bump minimum PHP version to 8.1
|
||||
|
||||
# 3.19.0 (2025-01-28)
|
||||
|
||||
@@ -112,9 +112,6 @@ class ArrayExpression extends AbstractExpression
|
||||
}
|
||||
|
||||
if ($nextIndex !== $key) {
|
||||
if (\is_int($key)) {
|
||||
$nextIndex = $key + 1;
|
||||
}
|
||||
$compiler
|
||||
->subcompile($pair['key'])
|
||||
->raw(' => ')
|
||||
|
||||
@@ -50,6 +50,11 @@ Twig supports array notation
|
||||
{{ does_not_exist[0]|default('ok') }}
|
||||
{{ does_not_exist[0].does_not_exist_either|default('ok') }}
|
||||
{{ does_not_exist[0]['does_not_exist_either']|default('ok') }}
|
||||
|
||||
{# indexes are kept #}
|
||||
{% set trad = {194:'ABC',141:'DEF',100:'GHI',170:'JKL',110:'MNO',111:'PQR'} %}
|
||||
{% set trad2 = {'194':'ABC','141':'DEF','100':'GHI','170':'JKL','110':'MNO','111':'PQR'} %}
|
||||
{{ trad == trad2 ? 'OK' : 'KO' }}
|
||||
--DATA--
|
||||
$objectStorage = new SplObjectStorage();
|
||||
$object = new stdClass();
|
||||
@@ -84,6 +89,8 @@ bar
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
|
||||
OK
|
||||
--DATA--
|
||||
return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'array_access' => new \ArrayObject(['a' => 'b']), 'object' => new stdClass()]
|
||||
--CONFIG--
|
||||
@@ -117,3 +124,5 @@ bar
|
||||
ok
|
||||
ok
|
||||
ok
|
||||
|
||||
OK
|
||||
|
||||
Reference in New Issue
Block a user