Commit Graph

76 Commits

Author SHA1 Message Date
Pascal CESCON - Amoifr c9c3b23a77 Fix the empty comment "{##}" being lexed as a documentation comment opening 2026-08-19 19:01:11 +02:00
Fabien Potencier 6806e30474 Attach documentation comments to nodes 2026-08-19 16:41:17 +02:00
Derrick Austin 153094b601 Fix a PHP 8.5 chr() deprecation when decoding octal string escapes
PHP 8.5 deprecates passing a value outside the [0, 255] range to chr().
The string-escape decoder in the lexer accepts up to three octal digits,
so an escape such as "\777" (= 511) reaches chr() out of range and emits:

    chr(): Providing a value not in-between 0 and 255 is deprecated ...

chr() already constrains the value with "% 256", so applying "% 256"
explicitly preserves the exact byte while silencing the deprecation. The
hex escape branch is unaffected because it is capped at two digits (0xff).
2026-06-13 07:22:26 +02:00
Fabien Potencier 3868bac531 Avoid allocating a normalized copy when counting newlines without carriage returns 2026-06-05 20:33:28 +02:00
Fabien Potencier a82782ac30 Report columns in syntax errors 2026-06-05 20:28:45 +02:00
Fabien Potencier 4943bb405c Track the source offset of each token 2026-06-05 20:28:45 +02:00
Fabien Potencier e5eb95d0d7 Add getOperatorTokens() to ExpressionParserInterface to separate operator token registration from parser identity 2026-02-24 21:13:06 +01:00
brandonkelly a9ac993938 Ensure filters/attributes aren't mistaken for operators 2026-02-24 21:10:18 +01:00
Fabien Potencier bfbbef05f2 Add the = assignment operator 2026-01-19 16:39:57 +01:00
Alexandre Daubois 9c6b95f2a6 Make in_array() calls strict 2025-02-19 15:29:33 +01:00
Fabien Potencier 3964aeba78 Add a proper prefix spread operator 2025-02-14 11:45:39 +01:00
Fabien Potencier 251c0b5da9 Fix CS 2025-02-14 08:45:28 +01:00
Fabien Potencier 561c6629e1 Remove obsolete code 2025-02-14 08:38:53 +01:00
Fabien Potencier f67078b5c4 Move Operators to ExpressionParsers, deprecate ExpressionParser 2025-02-14 08:38:53 +01:00
Fabien Potencier 42c82e1e9b Extract operators logic from ExpressionParser to their own classes 2025-02-14 08:38:53 +01:00
Fabien Potencier df877a1d53 Introduce operator classes to describe operators provided by extensions instead of arrays 2025-02-14 08:38:53 +01:00
Simon André 82be13429c Add return type annotations on Twig 3 to prepare Twig 4 2025-01-24 11:32:59 +01:00
Simon André da4d96692a Support underscores in number literals 2024-12-02 09:46:54 +01:00
Fabien Potencier ed1b44470f Improve deprecation messages 2024-10-11 08:16:49 +02:00
Fabien Potencier d9d8bb0df3 Add support for inline comments 2024-09-27 07:32:09 +02:00
Ruud Kamphuis 7256713c86 Improve escape deprecation message 2024-09-26 15:09:41 +02:00
Fabien Potencier 9e9f8110bd Replace most empty() calls 2024-09-11 07:44:00 +02:00
Ruud Kamphuis 90107929da Improve deprecation message
See https://github.com/twigphp/Twig/pull/4199#discussion_r1723456834
2024-08-21 19:36:27 +02:00
Fabien Potencier 675cb2d141 Fix CS 2024-08-18 19:25:19 +02:00
Simon André c662e0ce27 Remove remaining const optimizations
After #4198 some `Token::` const optimization remains.

This PR remove them.. **in case** it was not intended
2024-08-15 19:11:55 +02:00
Fabien Potencier cd0ac3cc0a Remove const optimization 2024-08-12 09:40:52 +02:00
Ruud Kamphuis bc6e36dee9 Optimize stripcslashes 2024-08-12 09:24:57 +02:00
Ruud Kamphuis c6656cf5d0 Deprecate unnecessary escape characters
See #4123 #2712

This allows to change the implementation in v4 so that we no longer have to escape backslashes.
2024-08-11 16:21:05 +02:00
Fabien Potencier b63bde3063 Optimize sprintf() calls for PHP 8.4 2024-06-21 08:16:55 +02:00
Fabien Potencier ccc20cbd1b Fix a warning 2024-04-24 08:06:10 +02:00
Daniel Gorgan 5a79652e7c Ensure Lexer:: is always initialized 2024-04-18 07:49:46 -04:00
Fabien Potencier af8ec178b6 Remove list() usage in code 2024-01-05 12:46:24 +01:00
Jérôme Tamarelle 1d5c09285f Use PHP 8.0 functions with polyfill 2023-10-08 17:11:07 +02:00
Fabien Potencier 5193653ecb Fix CS 2023-10-08 09:05:22 +02:00
Ryan Weaver ba4fe3ba34 Adding support for the ...spread operator on arrays and hashes 2023-07-20 16:08:57 +02:00
Fabien Potencier e2d668551b Merge branch '2.x' into 3.x
* 2.x:
  Making the Lexer initialize itself lazily, to avoid loading the extension set early
2023-05-03 19:47:35 +02:00
Ryan Weaver 2f7e868017 Making the Lexer initialize itself lazily, to avoid loading the extension set early 2023-05-03 19:47:11 +02:00
Fabien Potencier 13e360972a Merge branch '2.x' into 3.x
* 2.x:
  Fix CS
  Fix CS
  Migrate to the new PHP CS Fixer config file
  Fixing links
2021-05-12 09:45:40 +02:00
Fabien Potencier 2dd1d909b9 Fix CS 2021-05-12 09:37:17 +02:00
Fabien Potencier dba3517f4b Merge branch '2.x' into 3.x
* 2.x:
  Fix missing delimiter for preg_quote in lexer
2020-09-27 07:01:41 +02:00
Fabien Potencier f4aacffcbb Merge branch '1.x' into 2.x
* 1.x:
  Fix missing delimiter for preg_quote in lexer
2020-09-27 07:01:29 +02:00
wait 41605057a4 Fix missing delimiter for preg_quote in lexer 2020-09-27 06:58:41 +02:00
Fabien Potencier 57ca24c5f3 Merge branch '2.x' into 3.x
* 2.x:
  Fix a regression when not using a space before an operator
2020-07-06 15:35:21 +02:00
Fabien Potencier e063bab1a6 Merge branch '1.x' into 2.x
* 1.x:
  Fix a regression when not using a space before an operator
2020-07-06 15:35:12 +02:00
Fabien Potencier 841906b110 Fix a regression when not using a space before an operator 2020-07-06 14:40:02 +02:00
Fabien Potencier 1ed27f4d55 Merge branch '2.x' into 3.x
* 2.x:
  Fix regression
2020-02-21 09:29:22 +01:00
Fabien Potencier 8a4f881623 Merge branch '1.x' into 2.x
* 1.x:
  Fix regression
2020-02-21 09:29:15 +01:00
Fabien Potencier 77e5846161 Fix regression 2020-02-21 09:29:07 +01:00
Fabien Potencier a95ec00440 Merge branch '2.x' into 3.x
* 2.x:
  Fix ambiguous syntax parsing
2020-02-21 08:37:36 +01:00
Fabien Potencier 0686ccf278 Merge branch '1.x' into 2.x
* 1.x:
  Fix ambiguous syntax parsing
2020-02-21 08:37:29 +01:00