Commit Graph

6256 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 284a510651 Bump actions/cache for CI 2024-01-22 18:49:50 +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 cccf8b7e20 minor #3960 Add tests when a template doesn't have output nodes (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add tests when a template doesn't have output nodes

refs #3950 cc `@smnandre`

Commits
-------

d53509d4 Add tests when a template doesn't have output nodes
2024-01-11 08:39:22 +01:00
Fabien Potencier d53509d457 Add tests when a template doesn't have output nodes 2024-01-11 08:19:14 +01:00
Fabien Potencier c44bd1ff62 Optimize TextNodes 2024-01-10 20:22:00 +01:00
Fabien Potencier 8b4aa84fe1 minor #3958 Remove usage of list() in favor of [] (fabpot)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Remove usage of list() in favor of []

Commits
-------

af8ec178 Remove list() usage in code
9c0897fa Remove usage of list() in favor of []
2024-01-05 18:52:53 +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
Fabien Potencier b4c3c1c448 bug #3957 rework the CaptureNode implementation (xabbuh)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

rework the CaptureNode implementation

fixes #3955

Commits
-------

665dce89 rework the CaptureNode implementation
2024-01-01 15:44:03 +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 3f70efae53 feature #3954 Abstract node capture in its own Node (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Abstract node capture in its own Node

To prepare the work for #3950, I'd like to abstract the usage of `echo` into a single node that can be reused by other nodes.

The cache node is a good example of defining something that is more semantic are reusable as well. The node itself now just generates the wrapper that can then be returned, echoed, yielded, ...

Commits
-------

6ebbc305 Abstract node capture in its own Node
2023-12-30 13:02:32 +01:00
Fabien Potencier 6ebbc30593 Abstract node capture in its own Node 2023-12-30 10:14:36 +01:00
Fabien Potencier 14d199445a minor #3953 Remove usage of ReturnTypeWillChange (fabpot)
This PR was merged into the 4.x branch.

Discussion
----------

Remove usage of ReturnTypeWillChange

Commits
-------

13e57cb3 Remove usage of ReturnTypeWillChange
2023-12-25 10:50:04 +01:00
Fabien Potencier 13e57cb3fe Remove usage of ReturnTypeWillChange 2023-12-24 11:22:05 +01:00
Fabien Potencier 2956688a95 Merge branch '3.x' into 4.x
* 3.x:
  Add missing dots at the end of exception messages
2023-12-24 11:21:54 +01:00
Fabien Potencier 6e2f2655a8 Add missing dots at the end of exception messages 2023-12-24 09:54:44 +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
Fabien Potencier 61fff2dba2 minor #3952 Fix intl tests (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix intl tests

Commits
-------

44b3bac5 Fix intl tests
2023-12-24 09:45:15 +01:00
Fabien Potencier 44b3bac552 Fix intl tests 2023-12-24 09:42:15 +01:00
Fabien Potencier e7261632f3 minor #3853 Improve error message for constant(FQCN::class) (MalteWunsch)
This PR was merged into the 3.x branch.

Discussion
----------

Improve error message for `constant(FQCN::class)`

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
> Constant "Twig\Extension\CoreExtension::class" is undefined.

was generally helpful, but in this special case it was a bit misleading.

An alternative might be to determine and return the FCQN (e.g. via `substr($constant, 0, -7)`), but I'm not sure if this would be too much of a guess.

Commits
-------

3963851a Improve error message
2023-12-22 08:51:32 +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 d77586da99 Update CHANGELOG 2023-12-22 08:34:46 +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 7072a7256e bug #3949 Simplify code when using ob_* functions (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Simplify code when using `ob_*` functions

And fixed an edge case (see the modified test).

Commits
-------

0b9e30e3 Simplify code
2023-12-20 20:46:37 +01:00
Fabien Potencier 0b9e30e3d2 Simplify code 2023-12-20 20:43:49 +01:00
Fabien Potencier 87953c0d08 Merge branch '3.x' into 4.x
* 3.x:
  Fix bad merge
  Fix test without any assertions
  Simplify tests
2023-12-20 20:37:25 +01:00
Fabien Potencier 83dfc0f823 bug #3948 Simplify sandbox tests (fabpot)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Simplify sandbox tests

This allows to remove some unneeded assertions and fix static analysis checks.

Commits
-------

bc22e38c Fix bad merge
e6a98a00 Fix test without any assertions
fca89954 Simplify tests
2023-12-20 20:37:13 +01:00
Fabien Potencier bc22e38ce6 Fix bad merge 2023-12-20 20:34:40 +01:00
Fabien Potencier e6a98a000f Fix test without any assertions 2023-12-20 20:34:04 +01:00
Fabien Potencier fca89954f1 Simplify tests 2023-12-20 20:34:04 +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 e8c511ebc4 minor #3944 Add type hints to private properties (fabpot)
This PR was merged into the 4.x branch.

Discussion
----------

Add type hints to private properties

Commits
-------

35640b6d Add type hints to private properties
2023-12-14 20:45:59 +01:00
Fabien Potencier 35640b6d2d Add type hints to private properties 2023-12-14 20:43:37 +01:00
Fabien Potencier d2f493f67c minor #3941 add docs & links (lacpandore)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

add docs & links

Commits
-------

dd24d5bf add docs & links
2023-12-14 08:17:08 +01:00
Louis-Arnaud dd24d5bfd2 add docs & links 2023-12-14 08:17:06 +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 325ef1355e minor #3937 Remove deprecated code (fabpot)
This PR was merged into the 4.x branch.

Discussion
----------

Remove deprecated code

Commits
-------

f84c2172 Remove deprecated code
2023-12-10 21:04:17 +01:00