From 3e059001d6d597dd50ea7c74dd2464b4adea48d3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 27 Dec 2022 13:26:20 +0100 Subject: [PATCH 01/29] Prepare the 2.15.4 release --- CHANGELOG | 2 +- src/Environment.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9509a599303..db87b236046 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -# 2.15.4 (2022-XX-XX) +# 2.15.4 (2022-12-27) * Fix optimizing closures callbacks * Add a better exception when getting an undefined constant via `constant` diff --git a/src/Environment.php b/src/Environment.php index 463e4bc45a5..96f725106f3 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -38,12 +38,12 @@ */ class Environment { - public const VERSION = '2.15.4-DEV'; + public const VERSION = '2.15.4'; public const VERSION_ID = 21504; public const MAJOR_VERSION = 2; public const MINOR_VERSION = 15; public const RELEASE_VERSION = 4; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; private $charset; private $loader; From d573914760bd21f19ede028bfcd53a9a866a69e5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 27 Dec 2022 13:27:28 +0100 Subject: [PATCH 02/29] Bump version --- CHANGELOG | 4 ++++ src/Environment.php | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index db87b236046..0b5344858b5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +# 2.15.5 (2023-XX-XX) + + * n/a + # 2.15.4 (2022-12-27) * Fix optimizing closures callbacks diff --git a/src/Environment.php b/src/Environment.php index 96f725106f3..c5ab53f4656 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -38,12 +38,12 @@ */ class Environment { - public const VERSION = '2.15.4'; - public const VERSION_ID = 21504; + public const VERSION = '2.15.5-DEV'; + public const VERSION_ID = 21505; public const MAJOR_VERSION = 2; public const MINOR_VERSION = 15; - public const RELEASE_VERSION = 4; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 5; + public const EXTRA_VERSION = 'DEV'; private $charset; private $loader; From 7d326d512faf0e493a59a283e0313b013b4237d5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 27 Dec 2022 13:29:16 +0100 Subject: [PATCH 03/29] Bump version --- CHANGELOG | 3 +++ src/Environment.php | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b86b9e5fc08..c65ae265e5f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +# 3.5.1 (2023-XX-XX) + + * n/a # 3.5.0 (2022-12-27) * Make Twig\ExpressionParser non internal diff --git a/src/Environment.php b/src/Environment.php index c4f2885849d..1d999a33511 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -40,12 +40,12 @@ */ class Environment { - public const VERSION = '3.5.0'; - public const VERSION_ID = 30500; + public const VERSION = '3.5.1-DEV'; + public const VERSION_ID = 30501; public const MAJOR_VERSION = 3; public const MINOR_VERSION = 5; - public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 1; + public const EXTRA_VERSION = 'DEV'; private $charset; private $loader; From 8f8d67b4898d30a71334f12c286a0feca9f664d9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 27 Dec 2022 13:34:33 +0100 Subject: [PATCH 04/29] Add some missing functions in docs --- doc/functions/index.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/functions/index.rst b/doc/functions/index.rst index 97465ed0395..eebcd61c7ab 100644 --- a/doc/functions/index.rst +++ b/doc/functions/index.rst @@ -19,4 +19,10 @@ Functions range source country_timezones + country_names + currency_names + language_names + locale_names + script_names + timezone_names template_from_string From 459ed67e4889f2e8ec4f7073757bda378e63da31 Mon Sep 17 00:00:00 2001 From: "hubert.lenoir" Date: Wed, 28 Dec 2022 14:34:31 +0100 Subject: [PATCH 05/29] Add "has some" and "has every" expressions --- doc/templates.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/templates.rst b/doc/templates.rst index 380d42b4f37..580458cf732 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -505,7 +505,7 @@ Twig allows expressions everywhere. The operator precedence is as follows, with the lowest-precedence operators listed first: ``?:`` (ternary operator), ``b-and``, ``b-xor``, ``b-or``, ``or``, ``and``, ``==``, ``!=``, ``<=>``, ``<``, ``>``, ``>=``, ``<=``, - ``in``, ``matches``, ``starts with``, ``ends with``, ``..``, ``+``, ``-``, + ``in``, ``matches``, ``starts with``, ``ends with``, ``has every``, ``has some``, ``..``, ``+``, ``-``, ``~``, ``*``, ``/``, ``//``, ``%``, ``is`` (tests), ``**``, ``??``, ``|`` (filters), ``[]``, and ``.``: @@ -661,6 +661,20 @@ next section). {% if phone matches '/^[\\d\\.]+$/' %} {% endif %} +Check that a sequence or a mapping ``has every`` or ``has some`` of its elements +``true`` using an arrow function. The arrow function receives the value of the +sequence or mapping. + +.. code-block:: twig + + {% set sizes = [34, 36, 38, 40, 42] %} + + {% set hasOnlyOver38 = sizes has every v => v > 38 %} + {# hasOnlyOver38 is false #} + + {% set hasOver38 = sizes has some v => v > 38 %} + {# hasOver38 is true #} + Containment Operator ~~~~~~~~~~~~~~~~~~~~ From dc693725ea61b4a5179e72f002e2968e55b0690c Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Tue, 27 Dec 2022 13:58:24 +0100 Subject: [PATCH 06/29] Fix CHANGELOG --- CHANGELOG | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c65ae265e5f..68518ce96cf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,9 +3,9 @@ * n/a # 3.5.0 (2022-12-27) - * Make Twig\ExpressionParser non internal - * Add "some" and "every" filters - * Add Compile::reset( + * Make Twig\ExpressionParser non-internal + * Add "some" and "every" tests + * Add Compile::reset() * Throw a better runtime error when the "matches" regexp is not valid * Add "twig *_names" intl functions * Fix optimizing closures callbacks From 7b4d2a69f3a80dfaa6e9aaf17c14bde7eaf5fb96 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 28 Dec 2022 14:50:47 +0100 Subject: [PATCH 07/29] Tweak docs --- CHANGELOG | 2 +- doc/templates.rst | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 68518ce96cf..131bdadb148 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,7 +4,7 @@ # 3.5.0 (2022-12-27) * Make Twig\ExpressionParser non-internal - * Add "some" and "every" tests + * Add "has some" and "has every" operators * Add Compile::reset() * Throw a better runtime error when the "matches" regexp is not valid * Add "twig *_names" intl functions diff --git a/doc/templates.rst b/doc/templates.rst index 580458cf732..5e52326e442 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -505,7 +505,8 @@ Twig allows expressions everywhere. The operator precedence is as follows, with the lowest-precedence operators listed first: ``?:`` (ternary operator), ``b-and``, ``b-xor``, ``b-or``, ``or``, ``and``, ``==``, ``!=``, ``<=>``, ``<``, ``>``, ``>=``, ``<=``, - ``in``, ``matches``, ``starts with``, ``ends with``, ``has every``, ``has some``, ``..``, ``+``, ``-``, + ``in``, ``matches``, ``starts with``, ``ends with``, ``has every``, ``has + some``, ``..``, ``+``, ``-``, ``~``, ``*``, ``/``, ``//``, ``%``, ``is`` (tests), ``**``, ``??``, ``|`` (filters), ``[]``, and ``.``: @@ -661,9 +662,9 @@ next section). {% if phone matches '/^[\\d\\.]+$/' %} {% endif %} -Check that a sequence or a mapping ``has every`` or ``has some`` of its elements -``true`` using an arrow function. The arrow function receives the value of the -sequence or mapping. +Check that a sequence or a mapping ``has every`` or ``has some`` of its +elements return ``true`` using an arrow function. The arrow function receives +the value of the sequence or mapping: .. code-block:: twig From eb8bde3c41402fa97edc197fa98dd921f163b461 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 1 Jan 2023 09:42:51 +0100 Subject: [PATCH 08/29] Bump LICENSE year --- LICENSE | 2 +- extra/cssinliner-extra/LICENSE | 2 +- extra/html-extra/LICENSE | 2 +- extra/inky-extra/LICENSE | 2 +- extra/intl-extra/LICENSE | 2 +- extra/markdown-extra/LICENSE | 2 +- extra/string-extra/LICENSE | 2 +- extra/twig-extra-bundle/LICENSE | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/LICENSE b/LICENSE index 8711927f6d9..a2236f90d80 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2022 by the Twig Team. +Copyright (c) 2009-2023 by the Twig Team. All rights reserved. diff --git a/extra/cssinliner-extra/LICENSE b/extra/cssinliner-extra/LICENSE index 9c907a46a62..5c7ba0551cb 100644 --- a/extra/cssinliner-extra/LICENSE +++ b/extra/cssinliner-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Fabien Potencier +Copyright (c) 2019-2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/html-extra/LICENSE b/extra/html-extra/LICENSE index 9c907a46a62..5c7ba0551cb 100644 --- a/extra/html-extra/LICENSE +++ b/extra/html-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Fabien Potencier +Copyright (c) 2019-2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/inky-extra/LICENSE b/extra/inky-extra/LICENSE index 9c907a46a62..5c7ba0551cb 100644 --- a/extra/inky-extra/LICENSE +++ b/extra/inky-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Fabien Potencier +Copyright (c) 2019-2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/intl-extra/LICENSE b/extra/intl-extra/LICENSE index 9c907a46a62..5c7ba0551cb 100644 --- a/extra/intl-extra/LICENSE +++ b/extra/intl-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Fabien Potencier +Copyright (c) 2019-2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/markdown-extra/LICENSE b/extra/markdown-extra/LICENSE index 9c907a46a62..5c7ba0551cb 100644 --- a/extra/markdown-extra/LICENSE +++ b/extra/markdown-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Fabien Potencier +Copyright (c) 2019-2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/string-extra/LICENSE b/extra/string-extra/LICENSE index 9c907a46a62..5c7ba0551cb 100644 --- a/extra/string-extra/LICENSE +++ b/extra/string-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Fabien Potencier +Copyright (c) 2019-2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/twig-extra-bundle/LICENSE b/extra/twig-extra-bundle/LICENSE index 9c907a46a62..5c7ba0551cb 100644 --- a/extra/twig-extra-bundle/LICENSE +++ b/extra/twig-extra-bundle/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Fabien Potencier +Copyright (c) 2019-2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 44c46712b8b65317b4657a698ee94e8abc3ea602 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 3 Jan 2023 18:06:19 +0100 Subject: [PATCH 09/29] Fix error messages in sandboxed mode for has some and has every --- src/Extension/CoreExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php index 65caab31fe1..ca3d28bf305 100644 --- a/src/Extension/CoreExtension.php +++ b/src/Extension/CoreExtension.php @@ -1716,7 +1716,7 @@ function twig_array_reduce(Environment $env, $array, $arrow, $initial = null) function twig_array_some(Environment $env, $array, $arrow) { - twig_check_arrow_in_sandbox($env, $arrow, 'some', 'filter'); + twig_check_arrow_in_sandbox($env, $arrow, 'has some', 'operator'); foreach ($array as $k => $v) { if ($arrow($v, $k)) { @@ -1729,7 +1729,7 @@ function twig_array_some(Environment $env, $array, $arrow) function twig_array_every(Environment $env, $array, $arrow) { - twig_check_arrow_in_sandbox($env, $arrow, 'every', 'filter'); + twig_check_arrow_in_sandbox($env, $arrow, 'has every', 'operator'); foreach ($array as $k => $v) { if (!$arrow($v, $k)) { From 9527f93e759c4e5a23d116378044ab89b28dc1a5 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Sat, 21 Jan 2023 14:32:09 -0300 Subject: [PATCH 10/29] Update docs for filters that use the `calendar` option --- doc/filters/format_date.rst | 2 +- doc/filters/format_datetime.rst | 2 +- doc/filters/format_time.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/filters/format_date.rst b/doc/filters/format_date.rst index c4a900a4360..cd6beba9f5b 100644 --- a/doc/filters/format_date.rst +++ b/doc/filters/format_date.rst @@ -33,4 +33,4 @@ Arguments * ``dateFormat``: The date format * ``pattern``: A date time pattern * ``timezone``: The date timezone -* ``calendar``: The calendar (Gregorian by default) +* ``calendar``: The calendar ("gregorian" by default) diff --git a/doc/filters/format_datetime.rst b/doc/filters/format_datetime.rst index 9fed54f8ec9..e5c07228adb 100644 --- a/doc/filters/format_datetime.rst +++ b/doc/filters/format_datetime.rst @@ -97,6 +97,6 @@ Arguments * ``timeFormat``: The time format * ``pattern``: A date time pattern * ``timezone``: The date timezone name -* ``calendar``: The calendar (Gregorian by default) +* ``calendar``: The calendar ("gregorian" by default) .. _ICU user guide: https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax diff --git a/doc/filters/format_time.rst b/doc/filters/format_time.rst index 417b8a9c62b..1e213e6163b 100644 --- a/doc/filters/format_time.rst +++ b/doc/filters/format_time.rst @@ -33,4 +33,4 @@ Arguments * ``timeFormat``: The time format * ``pattern``: A date time pattern * ``timezone``: The date timezone -* ``calendar``: The calendar (Gregorian by default) +* ``calendar``: The calendar ("gregorian" by default) From 4f2f3f814e6d5dfab62a4fd5197ae9dfb021ef36 Mon Sep 17 00:00:00 2001 From: ju1ius Date: Thu, 19 Jan 2023 11:01:38 +0100 Subject: [PATCH 11/29] pass the current key to reduce filter's callback --- CHANGELOG | 1 + doc/filters/reduce.rst | 10 +++++----- src/Extension/CoreExtension.php | 13 +++++++------ tests/Fixtures/filters/reduce_key.test | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 tests/Fixtures/filters/reduce_key.test diff --git a/CHANGELOG b/CHANGELOG index 131bdadb148..28d5c7fae3d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * Fix optimizing closures callbacks * Add a better exception when getting an undefined constant via `constant` * Fix `if` nodes when outside of a block and with an empty body + * Arrow functions passed to the "reduce" filter now accept the current key as a third argument # 3.4.3 (2022-09-28) diff --git a/doc/filters/reduce.rst b/doc/filters/reduce.rst index 7df4646c745..72c68d0deb9 100644 --- a/doc/filters/reduce.rst +++ b/doc/filters/reduce.rst @@ -4,21 +4,21 @@ The ``reduce`` filter iteratively reduces a sequence or a mapping to a single value using an arrow function, so as to reduce it to a single value. The arrow function receives the return value of the previous iteration and the current -value of the sequence or mapping: +value and key of the sequence or mapping: .. code-block:: twig {% set numbers = [1, 2, 3] %} - {{ numbers|reduce((carry, v) => carry + v) }} - {# output 6 #} + {{ numbers|reduce((carry, v, k) => carry + v * k) }} + {# output 8 #} The ``reduce`` filter takes an ``initial`` value as a second argument: .. code-block:: twig - {{ numbers|reduce((carry, v) => carry + v, 10) }} - {# output 16 #} + {{ numbers|reduce((carry, v, k) => carry + v * k, 10) }} + {# output 18 #} Note that the arrow function has access to the current context. diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php index ca3d28bf305..ce846e91f74 100644 --- a/src/Extension/CoreExtension.php +++ b/src/Extension/CoreExtension.php @@ -1703,15 +1703,16 @@ function twig_array_reduce(Environment $env, $array, $arrow, $initial = null) { twig_check_arrow_in_sandbox($env, $arrow, 'reduce', 'filter'); - if (!\is_array($array)) { - if (!$array instanceof \Traversable) { - throw new RuntimeError(sprintf('The "reduce" filter only works with arrays or "Traversable", got "%s" as first argument.', \gettype($array))); - } + if (!\is_array($array) && !$array instanceof \Traversable) { + throw new RuntimeError(sprintf('The "reduce" filter only works with arrays or "Traversable", got "%s" as first argument.', \gettype($array))); + } - $array = iterator_to_array($array); + $accumulator = $initial; + foreach ($array as $key => $value) { + $accumulator = $arrow($accumulator, $value, $key); } - return array_reduce($array, $arrow, $initial); + return $accumulator; } function twig_array_some(Environment $env, $array, $arrow) diff --git a/tests/Fixtures/filters/reduce_key.test b/tests/Fixtures/filters/reduce_key.test new file mode 100644 index 00000000000..fe1fb0a7ac5 --- /dev/null +++ b/tests/Fixtures/filters/reduce_key.test @@ -0,0 +1,14 @@ +--TEST-- +"reduce" filter passes iterable key to callback +--TEMPLATE-- +{% set status_classes = { + 'success': 200, + 'warning': 400, + 'error': 500, +} %} + +{{ status_classes|reduce((carry, v, k) => status_code >= v ? k : carry, '') }} +--DATA-- +return ['status_code' => 404] +--EXPECT-- +warning From f52b45d226ff6409b45a07fe2bb3b8ca045bd2fe Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Tue, 31 Jan 2023 21:48:47 +0100 Subject: [PATCH 12/29] Minor: Fixing language --- doc/filters/striptags.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/filters/striptags.rst b/doc/filters/striptags.rst index d5f542b3d8b..64a9c8156fe 100644 --- a/doc/filters/striptags.rst +++ b/doc/filters/striptags.rst @@ -1,7 +1,7 @@ ``striptags`` ============= -The ``striptags`` filter strips SGML/XML tags and replace adjacent whitespace +The ``striptags`` filter strips SGML/XML tags and replaces adjacent whitespace characters by one space: .. code-block:: twig From f136668933b075a7bbb2d0197355ae65613a386a Mon Sep 17 00:00:00 2001 From: Jacob Richardson Date: Tue, 7 Feb 2023 17:06:12 +0000 Subject: [PATCH 13/29] Restores the leniency of the `matches` twig comparison, allowing null subject to result in a non-match. Resolves BC break introduced in PR https://github.com/twigphp/Twig/pull/3687 As per pattern in https://github.com/twigphp/Twig/pull/3617 --- src/Extension/CoreExtension.php | 6 +++--- tests/Fixtures/expressions/matches.test | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php index ce846e91f74..f99adda451b 100644 --- a/src/Extension/CoreExtension.php +++ b/src/Extension/CoreExtension.php @@ -1021,19 +1021,19 @@ function twig_compare($a, $b) /** * @param string $pattern - * @param string $subject + * @param string|null $subject * * @return int * * @throws RuntimeError When an invalid pattern is used */ -function twig_matches(string $regexp, string $str) +function twig_matches(string $regexp, ?string $str) { set_error_handler(function ($t, $m) use ($regexp) { throw new RuntimeError(sprintf('Regexp "%s" passed to "matches" is not valid', $regexp).substr($m, 12)); }); try { - return preg_match($regexp, $str); + return preg_match($regexp, $str ?? ''); } finally { restore_error_handler(); } diff --git a/tests/Fixtures/expressions/matches.test b/tests/Fixtures/expressions/matches.test index 95459c3b0f2..8f5e3669e61 100644 --- a/tests/Fixtures/expressions/matches.test +++ b/tests/Fixtures/expressions/matches.test @@ -4,9 +4,11 @@ Twig supports the "matches" operator {{ 'foo' matches '/o/' ? 'OK' : 'KO' }} {{ 'foo' matches '/^fo/' ? 'OK' : 'KO' }} {{ 'foo' matches '/O/i' ? 'OK' : 'KO' }} +{{ null matches '/o/' }} --DATA-- return [] --EXPECT-- OK OK OK +0 From 872646a70ff83b3628d50c9bafa117af9f1da59e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 8 Feb 2023 08:44:48 +0100 Subject: [PATCH 14/29] Fix LICENSE year --- LICENSE | 2 +- extra/cssinliner-extra/LICENSE | 2 +- extra/html-extra/LICENSE | 2 +- extra/inky-extra/LICENSE | 2 +- extra/intl-extra/LICENSE | 2 +- extra/markdown-extra/LICENSE | 2 +- extra/string-extra/LICENSE | 2 +- extra/twig-extra-bundle/LICENSE | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/LICENSE b/LICENSE index a2236f90d80..fd8234e511b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2023 by the Twig Team. +Copyright (c) 2009-present by the Twig Team. All rights reserved. diff --git a/extra/cssinliner-extra/LICENSE b/extra/cssinliner-extra/LICENSE index 5c7ba0551cb..f37c76b591d 100644 --- a/extra/cssinliner-extra/LICENSE +++ b/extra/cssinliner-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/html-extra/LICENSE b/extra/html-extra/LICENSE index 5c7ba0551cb..f37c76b591d 100644 --- a/extra/html-extra/LICENSE +++ b/extra/html-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/inky-extra/LICENSE b/extra/inky-extra/LICENSE index 5c7ba0551cb..f37c76b591d 100644 --- a/extra/inky-extra/LICENSE +++ b/extra/inky-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/intl-extra/LICENSE b/extra/intl-extra/LICENSE index 5c7ba0551cb..f37c76b591d 100644 --- a/extra/intl-extra/LICENSE +++ b/extra/intl-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/markdown-extra/LICENSE b/extra/markdown-extra/LICENSE index 5c7ba0551cb..f37c76b591d 100644 --- a/extra/markdown-extra/LICENSE +++ b/extra/markdown-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/string-extra/LICENSE b/extra/string-extra/LICENSE index 5c7ba0551cb..f37c76b591d 100644 --- a/extra/string-extra/LICENSE +++ b/extra/string-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extra/twig-extra-bundle/LICENSE b/extra/twig-extra-bundle/LICENSE index 5c7ba0551cb..f37c76b591d 100644 --- a/extra/twig-extra-bundle/LICENSE +++ b/extra/twig-extra-bundle/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 0752948cdf564f6f7932234037449f5567585251 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 8 Feb 2023 08:48:35 +0100 Subject: [PATCH 15/29] Update CHANGELOG --- CHANGELOG | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 28d5c7fae3d..408fcd259dd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ # 3.5.1 (2023-XX-XX) - * n/a + * Arrow functions passed to the "reduce" filter now accept the current key as a third argument + * Restores the leniency of the matches twig comparison + * Fix error messages in sandboxed mode for "has some" and "has every" + # 3.5.0 (2022-12-27) * Make Twig\ExpressionParser non-internal @@ -11,7 +14,6 @@ * Fix optimizing closures callbacks * Add a better exception when getting an undefined constant via `constant` * Fix `if` nodes when outside of a block and with an empty body - * Arrow functions passed to the "reduce" filter now accept the current key as a third argument # 3.4.3 (2022-09-28) From a6e0510cc793912b451fd40ab983a1d28f611c15 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 8 Feb 2023 08:49:20 +0100 Subject: [PATCH 16/29] Prepare the 3.5.1 release --- CHANGELOG | 2 +- src/Environment.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 408fcd259dd..fd2c9c62e6f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -# 3.5.1 (2023-XX-XX) +# 3.5.1 (2023-02-08) * Arrow functions passed to the "reduce" filter now accept the current key as a third argument * Restores the leniency of the matches twig comparison diff --git a/src/Environment.php b/src/Environment.php index 1d999a33511..dd721b41236 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -40,12 +40,12 @@ */ class Environment { - public const VERSION = '3.5.1-DEV'; + public const VERSION = '3.5.1'; public const VERSION_ID = 30501; public const MAJOR_VERSION = 3; public const MINOR_VERSION = 5; public const RELEASE_VERSION = 1; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; private $charset; private $loader; From 2bd9c96c74d6ae8523e61affee544ded2c795e27 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 8 Feb 2023 08:50:32 +0100 Subject: [PATCH 17/29] Fix LICENSE year --- extra/cache-extra/LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/cache-extra/LICENSE b/extra/cache-extra/LICENSE index efb17f98e7d..99c6bdf356e 100644 --- a/extra/cache-extra/LICENSE +++ b/extra/cache-extra/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021 Fabien Potencier +Copyright (c) 2021-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From e172f3c6f415c3fcefcf72b32379d1a9a66f5e5a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 8 Feb 2023 08:51:03 +0100 Subject: [PATCH 18/29] Bump version --- CHANGELOG | 4 ++++ src/Environment.php | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fd2c9c62e6f..568087f4623 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +# 3.5.2 (2023-XX-XX) + + * n/a + # 3.5.1 (2023-02-08) * Arrow functions passed to the "reduce" filter now accept the current key as a third argument diff --git a/src/Environment.php b/src/Environment.php index dd721b41236..5f91d6322cc 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -40,12 +40,12 @@ */ class Environment { - public const VERSION = '3.5.1'; - public const VERSION_ID = 30501; + public const VERSION = '3.5.2-DEV'; + public const VERSION_ID = 30502; public const MAJOR_VERSION = 3; public const MINOR_VERSION = 5; - public const RELEASE_VERSION = 1; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 2; + public const EXTRA_VERSION = 'DEV'; private $charset; private $loader; From 5776f76068dd2c56d302cde5bf4e726a1bb58e22 Mon Sep 17 00:00:00 2001 From: Quentin Schuler Date: Thu, 2 Feb 2023 09:24:56 +0100 Subject: [PATCH 19/29] Add the new PHP 8.0 IntlDateFormatter::RELATIVE_* constants for date formatting. --- doc/filters/format_datetime.rst | 6 +++ extra/intl-extra/IntlExtension.php | 45 ++++++++++++++++--- .../Tests/Fixtures/format_date_php8.test | 12 +++++ 3 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 extra/intl-extra/Tests/Fixtures/format_date_php8.test diff --git a/doc/filters/format_datetime.rst b/doc/filters/format_datetime.rst index e5c07228adb..8f3b46d479a 100644 --- a/doc/filters/format_datetime.rst +++ b/doc/filters/format_datetime.rst @@ -26,6 +26,12 @@ You can tweak the output for the date part and the time part: Supported values are: ``none``, ``short``, ``medium``, ``long``, and ``full``. +.. versionadded:: 3.6 + + ``relative_short``, ``relative_medium``, ``relative_long``, and ``relative_full`` are also supported when running on + PHP 8.0 and superior or when using a polyfill that define the ``IntlDateFormatter::RELATIVE_*`` constants and + associated behavior. + For greater flexibility, you can even define your own pattern (see the `ICU user guide`_ for supported patterns). diff --git a/extra/intl-extra/IntlExtension.php b/extra/intl-extra/IntlExtension.php index 76c2b271e71..955d6ec9233 100644 --- a/extra/intl-extra/IntlExtension.php +++ b/extra/intl-extra/IntlExtension.php @@ -26,7 +26,36 @@ final class IntlExtension extends AbstractExtension { - private const DATE_FORMATS = [ + private static function availableDateFormats(): array + { + static $formats = null; + + if (null !== $formats) { + return $formats; + } + + $formats = [ + 'none' => \IntlDateFormatter::NONE, + 'short' => \IntlDateFormatter::SHORT, + 'medium' => \IntlDateFormatter::MEDIUM, + 'long' => \IntlDateFormatter::LONG, + 'full' => \IntlDateFormatter::FULL, + ]; + + // Assuming that each `RELATIVE_*` constant are defined when one of them is. + if (\defined('IntlDateFormatter::RELATIVE_FULL')) { + $formats = array_merge($formats, [ + 'relative_short' => \IntlDateFormatter::RELATIVE_SHORT, + 'relative_medium' => \IntlDateFormatter::RELATIVE_MEDIUM, + 'relative_long' => \IntlDateFormatter::RELATIVE_LONG, + 'relative_full' => \IntlDateFormatter::RELATIVE_FULL, + ]); + } + + return $formats; + } + + private const TIME_FORMATS = [ 'none' => \IntlDateFormatter::NONE, 'short' => \IntlDateFormatter::SHORT, 'medium' => \IntlDateFormatter::MEDIUM, @@ -370,12 +399,14 @@ public function formatTime(Environment $env, $date, ?string $timeFormat = 'mediu private function createDateFormatter(?string $locale, ?string $dateFormat, ?string $timeFormat, string $pattern, \DateTimeZone $timezone, string $calendar): \IntlDateFormatter { - if (null !== $dateFormat && !isset(self::DATE_FORMATS[$dateFormat])) { - throw new RuntimeError(sprintf('The date format "%s" does not exist, known formats are: "%s".', $dateFormat, implode('", "', array_keys(self::DATE_FORMATS)))); + $dateFormats = self::availableDateFormats(); + + if (null !== $dateFormat && !isset($dateFormats[$dateFormat])) { + throw new RuntimeError(sprintf('The date format "%s" does not exist, known formats are: "%s".', $dateFormat, implode('", "', array_keys($dateFormats)))); } - if (null !== $timeFormat && !isset(self::DATE_FORMATS[$timeFormat])) { - throw new RuntimeError(sprintf('The time format "%s" does not exist, known formats are: "%s".', $timeFormat, implode('", "', array_keys(self::DATE_FORMATS)))); + if (null !== $timeFormat && !isset(self::TIME_FORMATS[$timeFormat])) { + throw new RuntimeError(sprintf('The time format "%s" does not exist, known formats are: "%s".', $timeFormat, implode('", "', array_keys(self::TIME_FORMATS)))); } if (null === $locale) { @@ -384,8 +415,8 @@ private function createDateFormatter(?string $locale, ?string $dateFormat, ?stri $calendar = 'gregorian' === $calendar ? \IntlDateFormatter::GREGORIAN : \IntlDateFormatter::TRADITIONAL; - $dateFormatValue = self::DATE_FORMATS[$dateFormat] ?? null; - $timeFormatValue = self::DATE_FORMATS[$timeFormat] ?? null; + $dateFormatValue = $dateFormats[$dateFormat] ?? null; + $timeFormatValue = self::TIME_FORMATS[$timeFormat] ?? null; if ($this->dateFormatterPrototype) { $dateFormatValue = $dateFormatValue ?: $this->dateFormatterPrototype->getDateType(); diff --git a/extra/intl-extra/Tests/Fixtures/format_date_php8.test b/extra/intl-extra/Tests/Fixtures/format_date_php8.test new file mode 100644 index 00000000000..67e0e6f4dbe --- /dev/null +++ b/extra/intl-extra/Tests/Fixtures/format_date_php8.test @@ -0,0 +1,12 @@ +--TEST-- +"format_date" filter +--CONDITION-- +PHP_VERSION_ID >= 80000 +--TEMPLATE-- +{{ 'today 23:39:12'|format_datetime('relative_short', 'none', locale='fr') }} +{{ 'today 23:39:12'|format_datetime('relative_full', 'full', locale='fr') }} +--DATA-- +return []; +--EXPECT-- +aujourd’hui +aujourd’hui à 23:39:12 temps universel coordonné From 08d2037f264e45113896fee52f31d688fe4fd57c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 9 Feb 2023 07:45:16 +0100 Subject: [PATCH 20/29] Bump version to 3.6 --- CHANGELOG | 2 +- composer.json | 5 ----- extra/cache-extra/composer.json | 5 ----- extra/cssinliner-extra/composer.json | 5 ----- extra/html-extra/composer.json | 5 ----- extra/inky-extra/composer.json | 5 ----- extra/intl-extra/composer.json | 5 ----- extra/markdown-extra/composer.json | 5 ----- extra/string-extra/composer.json | 5 ----- extra/twig-extra-bundle/composer.json | 5 ----- src/Environment.php | 8 ++++---- 11 files changed, 5 insertions(+), 50 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 568087f4623..2b71ee32c97 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -# 3.5.2 (2023-XX-XX) +# 3.6.0 (2023-XX-XX) * n/a diff --git a/composer.json b/composer.json index 18d3135bb4b..5e9999ae30f 100644 --- a/composer.json +++ b/composer.json @@ -41,10 +41,5 @@ "psr-4" : { "Twig\\Tests\\" : "tests/" } - }, - "extra": { - "branch-alias": { - "dev-master": "3.5-dev" - } } } diff --git a/extra/cache-extra/composer.json b/extra/cache-extra/composer.json index 05d75afd5f4..ec116d7d4ab 100644 --- a/extra/cache-extra/composer.json +++ b/extra/cache-extra/composer.json @@ -27,10 +27,5 @@ "exclude-from-classmap": [ "/Tests/" ] - }, - "extra": { - "branch-alias": { - "dev-master": "3.5-dev" - } } } diff --git a/extra/cssinliner-extra/composer.json b/extra/cssinliner-extra/composer.json index 1866f417ef9..a6799ed0dce 100644 --- a/extra/cssinliner-extra/composer.json +++ b/extra/cssinliner-extra/composer.json @@ -27,10 +27,5 @@ "exclude-from-classmap": [ "/Tests/" ] - }, - "extra": { - "branch-alias": { - "dev-master": "3.5-dev" - } } } diff --git a/extra/html-extra/composer.json b/extra/html-extra/composer.json index e5a545cf086..44f5a9faa46 100644 --- a/extra/html-extra/composer.json +++ b/extra/html-extra/composer.json @@ -27,10 +27,5 @@ "exclude-from-classmap": [ "/Tests/" ] - }, - "extra": { - "branch-alias": { - "dev-master": "3.5-dev" - } } } diff --git a/extra/inky-extra/composer.json b/extra/inky-extra/composer.json index 0a813c7bf2a..17e1be92c96 100644 --- a/extra/inky-extra/composer.json +++ b/extra/inky-extra/composer.json @@ -27,10 +27,5 @@ "exclude-from-classmap": [ "/Tests/" ] - }, - "extra": { - "branch-alias": { - "dev-master": "3.5-dev" - } } } diff --git a/extra/intl-extra/composer.json b/extra/intl-extra/composer.json index 24f3f0577e3..d357ad7254e 100644 --- a/extra/intl-extra/composer.json +++ b/extra/intl-extra/composer.json @@ -27,10 +27,5 @@ "exclude-from-classmap": [ "/Tests/" ] - }, - "extra": { - "branch-alias": { - "dev-master": "3.5-dev" - } } } diff --git a/extra/markdown-extra/composer.json b/extra/markdown-extra/composer.json index f26143525a8..20389ff9b24 100644 --- a/extra/markdown-extra/composer.json +++ b/extra/markdown-extra/composer.json @@ -30,10 +30,5 @@ "exclude-from-classmap": [ "/Tests/" ] - }, - "extra": { - "branch-alias": { - "dev-master": "3.5-dev" - } } } diff --git a/extra/string-extra/composer.json b/extra/string-extra/composer.json index 2b4a6950e6e..ed5d3ffa2f1 100644 --- a/extra/string-extra/composer.json +++ b/extra/string-extra/composer.json @@ -28,10 +28,5 @@ "exclude-from-classmap": [ "/Tests/" ] - }, - "extra": { - "branch-alias": { - "dev-master": "3.5-dev" - } } } diff --git a/extra/twig-extra-bundle/composer.json b/extra/twig-extra-bundle/composer.json index 3e183704493..b7f739bdf1f 100644 --- a/extra/twig-extra-bundle/composer.json +++ b/extra/twig-extra-bundle/composer.json @@ -36,10 +36,5 @@ "exclude-from-classmap": [ "/Tests/" ] - }, - "extra": { - "branch-alias": { - "dev-master": "3.5-dev" - } } } diff --git a/src/Environment.php b/src/Environment.php index 5f91d6322cc..39b7cec2f65 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -40,11 +40,11 @@ */ class Environment { - public const VERSION = '3.5.2-DEV'; - public const VERSION_ID = 30502; + public const VERSION = '3.6.0-DEV'; + public const VERSION_ID = 30600; public const MAJOR_VERSION = 3; - public const MINOR_VERSION = 5; - public const RELEASE_VERSION = 2; + public const MINOR_VERSION = 3; + public const RELEASE_VERSION = 0; public const EXTRA_VERSION = 'DEV'; private $charset; From d140542c2ef7a3ca7f31acf4d02425a3eadd9c81 Mon Sep 17 00:00:00 2001 From: Tobias Meindl <17339632+tobilektri@users.noreply.github.com> Date: Wed, 15 Feb 2023 10:01:39 +0100 Subject: [PATCH 21/29] Allow psr/container 2.0.2 Should allow psr/container 2.0.2 - not only 1.1.2 Changes: https://github.com/php-fig/container/compare/2.0.2...1.1.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5e9999ae30f..aeea64053ff 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ }, "require-dev": { "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0", - "psr/container": "^1.0" + "psr/container": "^1.0|^2.0" }, "autoload": { "psr-4" : { From 19be50ff01b5acd85d810df1aaefd7300de92ce9 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Tue, 11 Apr 2023 12:35:17 +0200 Subject: [PATCH 22/29] Adding mb_strlen --- doc/filters/length.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/filters/length.rst b/doc/filters/length.rst index d36712233cd..a9dfae423ca 100644 --- a/doc/filters/length.rst +++ b/doc/filters/length.rst @@ -12,8 +12,12 @@ it will return the length of the string provided by that method. For objects that implement the ``Traversable`` interface, ``length`` will use the return value of the ``iterator_count()`` method. +For strings, `mb_strlen()`_ is used. + .. code-block:: twig {% if users|length > 10 %} ... {% endif %} + +.. _mb_strlen(): https://www.php.net/manual/function.mb-strlen.php From b7a8ebbe6f1811844d561f5dcbf468cdf5457e4c Mon Sep 17 00:00:00 2001 From: "Phil E. Taylor" Date: Fri, 14 Apr 2023 12:03:02 +0100 Subject: [PATCH 23/29] return annotation to suppress deprecation warning --- extra/twig-extra-bundle/TwigExtraBundle.php | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/twig-extra-bundle/TwigExtraBundle.php b/extra/twig-extra-bundle/TwigExtraBundle.php index 5ed32a8ccca..a9c8f734bf8 100644 --- a/extra/twig-extra-bundle/TwigExtraBundle.php +++ b/extra/twig-extra-bundle/TwigExtraBundle.php @@ -17,6 +17,7 @@ class TwigExtraBundle extends Bundle { + /** @return void */ public function build(ContainerBuilder $container) { parent::build($container); From 9bb05acae41a0f575eb3914c1e80a99c6334ca33 Mon Sep 17 00:00:00 2001 From: Terence Eden Date: Mon, 24 Apr 2023 22:26:49 +0100 Subject: [PATCH 24/29] Put example all on one line Fixes #3833 --- doc/tags/if.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/tags/if.rst b/doc/tags/if.rst index 2d7475227c1..0523cb1ac19 100644 --- a/doc/tags/if.rst +++ b/doc/tags/if.rst @@ -26,8 +26,7 @@ You can also test if an array is not empty: .. note:: - If you want to test if the variable is defined, use ``if users is - defined`` instead. + If you want to test if the variable is defined, use ``if users is defined`` instead. You can also use ``not`` to check for values that evaluate to ``false``: From 2f7e868017acc698228446041a79ee786abf77bd Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Wed, 3 May 2023 06:40:00 -0400 Subject: [PATCH 25/29] Making the Lexer initialize itself lazily, to avoid loading the extension set early --- src/Lexer.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Lexer.php b/src/Lexer.php index edde9a7a0cb..78931d7119d 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -21,6 +21,8 @@ */ class Lexer { + private $isInitialized = false; + private $tokens; private $code; private $cursor; @@ -63,6 +65,15 @@ public function __construct(Environment $env, array $options = []) 'whitespace_line_chars' => ' \t\0\x0B', 'interpolation' => ['#{', '}'], ], $options); + } + + private function initialize() + { + if ($this->isInitialized) { + return; + } + + $this->isInitialized = true; // when PHP 7.3 is the min version, we will be able to remove the '#' part in preg_quote as it's part of the default $this->regexes = [ @@ -155,6 +166,8 @@ public function __construct(Environment $env, array $options = []) public function tokenize(Source $source) { + $this->initialize(); + $this->source = $source; $this->code = str_replace(["\r\n", "\r"], "\n", $source->getCode()); $this->cursor = 0; From 17bf0637d95afe89e198a487a6e7289d0e6970b1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 May 2023 19:49:13 +0200 Subject: [PATCH 26/29] Update CHANGELOG --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 0b5344858b5..9cc1d9a7191 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ # 2.15.5 (2023-XX-XX) - * n/a + * Make the Lexer initialize itself lazily # 2.15.4 (2022-12-27) From fc02a6af3eeb97c4bf5650debc76c2eda85ac22e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 May 2023 19:49:41 +0200 Subject: [PATCH 27/29] Prepare the 2.15.5 release --- CHANGELOG | 2 +- src/Environment.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9cc1d9a7191..a48393ad05a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -# 2.15.5 (2023-XX-XX) +# 2.15.5 (2023-05-03) * Make the Lexer initialize itself lazily diff --git a/src/Environment.php b/src/Environment.php index c5ab53f4656..9cebf35d56f 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -38,12 +38,12 @@ */ class Environment { - public const VERSION = '2.15.5-DEV'; + public const VERSION = '2.15.5'; public const VERSION_ID = 21505; public const MAJOR_VERSION = 2; public const MINOR_VERSION = 15; public const RELEASE_VERSION = 5; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; private $charset; private $loader; From 0911e406751e6be83bad6debd25f6d3daf994325 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 May 2023 21:06:32 +0200 Subject: [PATCH 28/29] Update CHANGELOG --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index d28ae6a8444..cbe1a076c79 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ # 3.6.0 (2023-XX-XX) + * Allow psr/container 2.0 + * Add the new PHP 8.0 IntlDateFormatter::RELATIVE_* constants for date formatting * Make the Lexer initialize itself lazily # 3.5.1 (2023-02-08) From 106c170d08e8415d78be2d16c3d057d0d108262b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 May 2023 21:06:57 +0200 Subject: [PATCH 29/29] Prepare the 3.6.0 release --- CHANGELOG | 2 +- src/Environment.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cbe1a076c79..46134b232d5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -# 3.6.0 (2023-XX-XX) +# 3.6.0 (2023-05-03) * Allow psr/container 2.0 * Add the new PHP 8.0 IntlDateFormatter::RELATIVE_* constants for date formatting diff --git a/src/Environment.php b/src/Environment.php index 39b7cec2f65..4b7d989bbef 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -40,12 +40,12 @@ */ class Environment { - public const VERSION = '3.6.0-DEV'; + public const VERSION = '3.6.0'; public const VERSION_ID = 30600; public const MAJOR_VERSION = 3; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; private $charset; private $loader;