Commit Graph

897 Commits

Author SHA1 Message Date
Fabien Potencier d234a60efa Merge branch '3.x' into 4.x
* 3.x:
  Bump actions/cache for CI
  Remove an obsolete comment
  Throws proper Twig exception when using cycle on an empty array
  Add tests when a template doesn't have output nodes
  Optimize TextNodes
  Remove list() usage in code
  Remove usage of list() in favor of []
2024-01-22 18:50:54 +01:00
Fabien Potencier 4c179c8a64 bug #3961 Throws proper Twig exception when using cycle on an empty array (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Throws proper Twig exception when using cycle on an empty array

Closes #3925

Commits
-------

d21666f7 Throws proper Twig exception when using cycle on an empty array
2024-01-12 12:20:12 +01:00
Fabien Potencier 9ef031efdc Remove an obsolete comment 2024-01-12 08:20:25 +01:00
Fabien Potencier d21666f728 Throws proper Twig exception when using cycle on an empty array 2024-01-11 21:47:04 +01:00
Fabien Potencier 433189bb5a feature #3959 Optimize TextNodes (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Optimize TextNodes

Not a great perf optimization, but it makes the node graph simpler which helps when we need to debug templates.

Commits
-------

c44bd1ff Optimize TextNodes
2024-01-11 14:01:35 +01:00
Fabien Potencier c44bd1ff62 Optimize TextNodes 2024-01-10 20:22:00 +01:00
Fabien Potencier af8ec178b6 Remove list() usage in code 2024-01-05 12:46:24 +01:00
Fabien Potencier 9c0897fa2c Remove usage of list() in favor of [] 2024-01-05 09:48:24 +01:00
Fabien Potencier 82e98ceff9 Merge branch '3.x' into 4.x
* 3.x:
  rework the CaptureNode implementation
2024-01-01 15:48:17 +01:00
Christian Flothmann 665dce899f rework the CaptureNode implementation 2024-01-01 15:43:59 +01:00
Fabien Potencier 2d19b9a8f0 Merge branch '3.x' into 4.x
* 3.x:
  Abstract node capture in its own Node
2023-12-30 13:06:11 +01:00
Fabien Potencier 6ebbc30593 Abstract node capture in its own Node 2023-12-30 10:14:36 +01:00
Fabien Potencier 13e57cb3fe Remove usage of ReturnTypeWillChange 2023-12-24 11:22:05 +01:00
Fabien Potencier fa91edfcc6 Merge branch '3.x' into 4.x
* 3.x:
  Fix intl tests
  Improve error message
  Bump version
  Update CHANGELOG
2023-12-24 09:45:46 +01:00
Malte Wunsch 3963851a41 Improve error message
It is not obvious that you cannot use the Twig function `constant` to get the special `::class` constants of classes like so: `{{ constant('Twig\\Extension\\CoreExtension::class') }}`, due to the underlying PHP function `\constant()`.

The previous error message in this case: 'Constant "Twig\Extension\CoreExtension::class" is undefined.' was not very helpful.
2023-12-22 08:51:25 +01:00
Fabien Potencier 4c621adb49 Bump version 2023-12-22 08:35:50 +01:00
Fabien Potencier d1824b237b Fix bug 2023-12-20 20:50:18 +01:00
Fabien Potencier 3d849eab57 Merge branch '3.x' into 4.x
* 3.x:
  Simplify code
2023-12-20 20:48:01 +01:00
Fabien Potencier 0b9e30e3d2 Simplify code 2023-12-20 20:43:49 +01:00
Fabien Potencier bc22e38ce6 Fix bad merge 2023-12-20 20:34:40 +01:00
Fabien Potencier d27c50850d Merge branch '3.x' into 4.x
* 3.x:
  Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source
  add docs & links
2023-12-19 08:20:44 +01:00
Fabien Potencier 204cd6f412 Merge branch '2.x' into 3.x
* 2.x:
  Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source
2023-12-19 08:19:15 +01:00
Fabien Potencier a4974b29a0 feature #3893 Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source (YSaxon)
This PR was squashed before being merged into the 2.x branch.

Discussion
----------

Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source

This is needed to patch some downstream vulnerabilities which I won't describe here.
I wrote `@fabpot` an email about this with more details a few weeks ago.

Generally the Sandbox can be enabled for a given template in either of two ways:
* Globally
* Including the template from another template in which we use the sandbox tag or parameter

This pull request adds a third way
* Using a SourcePolicy to selectively sandbox templates based on their Source object

Commits
-------

a18da161 Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source
2023-12-19 08:18:38 +01:00
Yaakov Saxon a18da1614a Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source 2023-12-19 08:18:35 +01:00
Fabien Potencier 35640b6d2d Add type hints to private properties 2023-12-14 20:43:37 +01:00
Fabien Potencier ffa55e8cae minor #3942 Use DateTimeImmutable (fabpot)
This PR was merged into the 4.x branch.

Discussion
----------

Use DateTimeImmutable

Commits
-------

b3e8b8ac Use DateTimeImmutable
2023-12-13 12:55:07 +01:00
Fabien Potencier b3e8b8ac39 Use DateTimeImmutable 2023-12-12 22:53:10 +01:00
Fabien Potencier 1493fdfb19 Remove deprecated method 2023-12-11 13:46:08 +01:00
Fabien Potencier f84c2172bf Remove deprecated code 2023-12-10 21:02:11 +01:00
Fabien Potencier ac423430aa Merge branch '3.x' into 4.x
* 3.x:
  Fix CS
  Move functions for CoreExtension
  Move functions for EscaperExtension
  Move functions for StringLoaderExtension
  Move functions for DebugExtension
  Move functions for MarkdownExtension
  Move functions for InkyExtension
  Move functions for CssInlinerExtension
  Move functions for HtmlExtension
  Deprecate internal extension functions in favor of methods on the extension classes
  Tweak deprecated docs
2023-12-10 20:55:15 +01:00
Fabien Potencier aa7c454e2d Fix CS 2023-12-10 20:34:32 +01:00
Fabien Potencier 54d34b969b Move functions for CoreExtension 2023-12-10 20:13:10 +01:00
Fabien Potencier 72071e8ece Move functions for EscaperExtension 2023-12-10 11:49:57 +01:00
Fabien Potencier 196e91dd72 Move functions for StringLoaderExtension 2023-12-10 11:38:36 +01:00
Fabien Potencier d4d016034c Move functions for DebugExtension 2023-12-10 11:35:00 +01:00
Fabien Potencier c8d6df7eb2 Remove usage of isset before array_key_exists as performance is not an issue anymore 2023-12-09 17:24:12 +01:00
Fabien Potencier bce22e4c32 Use named arguments 2023-12-09 17:18:55 +01:00
Fabien Potencier a64561b420 Simplify code 2023-12-09 17:18:14 +01:00
Fabien Potencier 0668be9e76 Use arrow function 2023-12-09 15:33:38 +01:00
Fabien Potencier 06d9fc6ad0 Use is_countable() 2023-12-09 15:33:38 +01:00
Fabien Potencier 89d37cd510 Use get_debug_type() 2023-12-09 15:33:38 +01:00
Fabien Potencier 308aa5ba45 Remove usage of list() 2023-12-09 15:33:38 +01:00
Fabien Potencier a42eba63c5 Use match instead of switch 2023-12-09 15:33:38 +01:00
Fabien Potencier fed8dd102b Use ::class 2023-12-09 15:33:38 +01:00
Fabien Potencier b9cf29d53d Remove obsolete code 2023-12-09 14:56:21 +01:00
Fabien Potencier 583d7b2d2c Remove hack to inline throwing an exception 2023-12-09 14:52:04 +01:00
Fabien Potencier 3d5ad9ac51 Remove obsolete code 2023-12-09 14:50:25 +01:00
Fabien Potencier 3472ae1241 Simplify code 2023-12-09 14:50:13 +01:00
Fabien Potencier f930a284fe Bump to 4.0 and require PHP 8.2 2023-12-09 13:45:50 +01:00
Fabien Potencier aeeec9a5e9 Bump version 2023-11-21 19:55:42 +01:00