From 2024406e8ec50078066823f3fa6c28bb22b5f04a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 17 Oct 2019 09:32:17 +0200 Subject: [PATCH 1/2] Fix phpdoc --- src/Environment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Environment.php b/src/Environment.php index f5d570dad..681c24684 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -515,7 +515,7 @@ class Environment * * This method should not be used as a generic way to load templates. * - * @param string $template The template name + * @param string $template The template source * @param string $name An optional name of the template to be used in error messages * * @return TemplateWrapper A template instance representing the given template name From 6092135057c0233c3176cd170d23452215de055f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 22 Oct 2019 17:32:36 +0200 Subject: [PATCH 2/2] Add support for exponential numbers --- CHANGELOG | 2 +- src/Lexer.php | 2 +- tests/Fixtures/expressions/exponential_numbers.test | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tests/Fixtures/expressions/exponential_numbers.test diff --git a/CHANGELOG b/CHANGELOG index ae0b425e8..95482c629 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * 1.42.4 (2019-XX-XX) - * n/a + * added supported for exponential numbers * 1.42.3 (2019-08-24) diff --git a/src/Lexer.php b/src/Lexer.php index 8cae3597f..697a6cfa1 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -47,7 +47,7 @@ class Lexer implements \Twig_LexerInterface const STATE_INTERPOLATION = 4; const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A'; - const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A'; + const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?([Ee][\+\-][0-9]+)?/A'; const REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As'; const REGEX_DQ_STRING_DELIM = '/"/A'; const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As'; diff --git a/tests/Fixtures/expressions/exponential_numbers.test b/tests/Fixtures/expressions/exponential_numbers.test new file mode 100644 index 000000000..f403110bc --- /dev/null +++ b/tests/Fixtures/expressions/exponential_numbers.test @@ -0,0 +1,8 @@ +--TEST-- +Twig manages exponentiel numbers correctly +--TEMPLATE-- +{{ 1.99E+3 }} +--DATA-- +return [] +--EXPECT-- +1990