Commit Graph

7061 Commits

Author SHA1 Message Date
Lorenz d58ac9a1a8 docs and changelog 2025-01-12 18:45:53 +01:00
Lorenz edecc13f08 typehint instead of checkArrow 2025-01-12 18:44:45 +01:00
Lorenz f27115857d checkArrow, typehints 2025-01-12 18:44:45 +01:00
Lorenz 8b432758f6 invoke filter 2025-01-12 18:44:45 +01:00
Fabien Potencier 9d1397afa4 feature #4536 Make {} optional for the types tag (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Make {} optional for the types tag

Closes #4532

Commits
-------

dff6fdd675 Make {} optional for the types tag
2025-01-10 08:28:17 +01:00
Fabien Potencier dff6fdd675 Make {} optional for the types tag 2025-01-06 13:53:28 +01:00
Fabien Potencier fb715039c3 minor #4535 Remove the note about types mapping argument (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Remove the note about types mapping argument

Refs #4532

Commits
-------

36ff3fa3b8 Remove the note about types mapping argument
2025-01-06 13:38:16 +01:00
Fabien Potencier 36ff3fa3b8 Remove the note about types mapping argument 2025-01-06 10:35:13 +01:00
Fabien Potencier 8689d46906 minor #4531 Add a note on the types locality (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add a note on the types locality

For your information `@drjayvee` `@ruudk`

Commits
-------

e7ae984e36 Add a note on the types locality
2025-01-04 09:42:25 +01:00
Fabien Potencier 5dd37d8a5a feature #4513 Add getLastModified() to extensions (GromNaN)
This PR was merged into the 3.x branch.

Discussion
----------

Add `getLastModified()` to extensions

Give to extensions the ability to set a last modification date for cache invalidation.

### Runtime

Currently, the cache is not invalidated when the signature of a runtime method is modified. This is an issue for templates that use named arguments, as argument names have an impact on the generated class.

With this change, extensions using runtime classes can compute a modification date by including the files on which they depend.

By default, the `AbstractExtension` checks if there is a file for the runtime class with the same name of the
This is the convention applied in [Symfony](https://github.com/symfony/symfony/tree/7.3/src/Symfony/Bridge/Twig/Extension) and Twig Extra: `MarkdownExtension` has `MarkdownRuntime`.

### Attribute

Contributing to https://github.com/twigphp/Twig/pull/3916.

The extension class that will get the configuration from attributes will be able to track the classes having attributes to find the last modification date of all this classes.

### ~BC break~

~In Twig 4.0, the method `getLastModified` will be added to `ExtensionInterface`. It is extremely rare to implement this interface without extending `AbstractExtension`. So adding this method to the interface shouldn't be a problem as the base class has an implementation.~

Commits
-------

d8fe3bd1ec Add `LastModifiedExtensionInterface` and implementation in `AbstractExtension` to track modification of runtime classes
2025-01-03 09:34:59 +01:00
Fabien Potencier e7ae984e36 Add a note on the types locality 2025-01-03 08:18:11 +01:00
Fabien Potencier 053572ed56 Fix CS 2025-01-03 08:17:25 +01:00
Fabien Potencier d19f56f882 minor #4530 Use spl_object_id() instead of spl_object_hash() (rosier)
This PR was merged into the 3.x branch.

Discussion
----------

Use spl_object_id() instead of spl_object_hash()

Small performance tweak.

Commits
-------

51bf2ca737 Use spl_object_id() instead of spl_object_hash()
2025-01-03 08:09:15 +01:00
Fabien Potencier 774254710f minor #4529 Fix typo in the docs (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix typo in the docs

Commits
-------

f2f03d7629 Fix typos in the docs
2025-01-03 07:58:16 +01:00
Fabien Potencier f2f03d7629 Fix typos in the docs 2025-01-02 21:31:30 +01:00
Jan Rosier 51bf2ca737 Use spl_object_id() instead of spl_object_hash() 2025-01-02 21:11:52 +01:00
Jérôme Tamarelle d8fe3bd1ec Add LastModifiedExtensionInterface and implementation in AbstractExtension to track modification of runtime classes 2025-01-02 14:50:18 +01:00
Fabien Potencier 4a871c1196 minor #4525 Optimize NameExpression compilation (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Optimize NameExpression compilation

Commits
-------

efd12ef0cc Optimize NameExpression compilation
2025-01-02 14:38:52 +01:00
Fabien Potencier 91c8c19026 Bump version 2025-01-02 14:38:21 +01:00
Fabien Potencier efd12ef0cc Optimize NameExpression compilation 2025-01-02 12:32:36 +01:00
Fabien Potencier 15ef38c661 minor #4521 Fix typo in enum twig doc functions (BaptisteChabrol)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Fix typo in enum twig doc functions

Commits
-------

3889bc7b18 Fix typo in enum twig doc functions
2025-01-02 09:42:21 +01:00
Baptiste 3889bc7b18 Fix typo in enum twig doc functions 2025-01-02 09:42:18 +01:00
Fabien Potencier 708b8d0421 minor #4524 Remove "dead method" in ModuleNode (smnandre)
This PR was merged into the 3.x branch.

Discussion
----------

Remove "dead method" in ModuleNode

This method is not used after 1.x (it was used [in the compileConstructor](https://github.com/twigphp/Twig/blob/b1f009c449e435a0384814e67205d9190a4d050e/src/Node/ModuleNode.php#L206)) and has no caller anymore [in 2.x ](https://github.com/twigphp/Twig/blob/19185947ec75d433a3ac650af32fc05649b95ee1/src/Node/ModuleNode.php#L174)

ModuleNode is [marked final](https://github.com/twigphp/Twig/blob/d184e9fe12e1a8d219a95638ee78ad577a59e299/src/Node/ModuleNode.php#L31) in 3.x so I guess we can remove it safely.

Commits
-------

81ebebb210 Remove dead method in ModuleNode
2025-01-02 09:39:29 +01:00
Simon André 81ebebb210 Remove dead method in ModuleNode
This method is not used after 1.x (it was used in the compileConstructor)https://github.com/twigphp/Twig/blob/b1f009c449e435a0384814e67205d9190a4d050e/src/Node/ModuleNode.php#L206 and has no caller since 2.x https://github.com/twigphp/Twig/blob/19185947ec75d433a3ac650af32fc05649b95ee1/src/Node/ModuleNode.php#L174

ModuleNode is marked final so I guess we can remove it safely.
2025-01-02 07:17:52 +01:00
Fabien Potencier d184e9fe12 Bump version 2024-12-29 11:52:41 +01:00
Fabien Potencier acffa88cc2 Prepare the 3.18.0 release v3.18.0 2024-12-29 11:51:50 +01:00
Fabien Potencier 77d36abcb7 bug #4467 Add support for Twig\Markup (nlemoine)
This PR was merged into the 3.x branch.

Discussion
----------

Add support for `Twig\Markup`

Commits
-------

8158dabc17 Add support for `Twig\Markup`
2024-12-29 11:36:27 +01:00
Nicolas Lemoine 8158dabc17 Add support for Twig\Markup
Co-authored-by: Fabien Potencier <fabien@potencier.org>
2024-12-29 11:29:59 +01:00
Fabien Potencier 38688f739d minor #4506 Add a test (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add a test

Commits
-------

2a6c986e85 Add a test
2024-12-29 11:23:06 +01:00
Fabien Potencier 2e13a83fe7 bug #4519 Fix unary operator precedence change (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix unary operator precedence change

Closes #4503

Commits
-------

2cf1939d01 Fix unary operator precedence change
2024-12-28 15:08:00 +01:00
Fabien Potencier 2cf1939d01 Fix unary operator precedence change 2024-12-28 11:29:38 +01:00
Fabien Potencier c7be388939 minor #4517 Replace Twigfiddle by the new Twig playground (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Replace Twigfiddle by the new Twig playground

https://symfony.com/blog/introducing-the-new-twig-playground

Commits
-------

4b87103468 Replace Twigfiddle by the new Twig playground
2024-12-26 14:59:15 +01:00
Fabien Potencier 4b87103468 Replace Twigfiddle by the new Twig playground 2024-12-26 14:58:29 +01:00
Fabien Potencier 681af9ddc1 bug #4516 Fix MacroNode $name argument can be overridden (smnandre)
This PR was merged into the 3.x branch.

Discussion
----------

Fix MacroNode $name argument can be overridden

Fix #4515

Commits
-------

dc329fd44e Fix MacroNode $name argument can be overridden
2024-12-26 11:03:16 +01:00
Simon André dc329fd44e Fix MacroNode $name argument can be overridden
Fix #4515
2024-12-26 10:28:13 +01:00
Fabien Potencier c1f7277b7b bug #4511 Ignore exceptions from undefined handlers when using the guard tag (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Ignore exceptions from undefined handlers when using the guard tag

Fixes #4505

Commits
-------

b53c639f7d Ignore exceptions from undefined handlers when using the guard tag
2024-12-20 07:51:39 +01:00
Fabien Potencier b53c639f7d Ignore exceptions from undefined handlers when using the guard tag 2024-12-19 15:10:50 +01:00
Fabien Potencier 91e609663e minor #4510 [Doc] Update the docs about attribute() function (javiereguiluz)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

[Doc] Update the docs about attribute() function

I Was fixing `filter` -> `function` error, but I realized that we could expand the docs of `attribute()` a bit, even if it's deprecated 🙏

Commits
-------

84daad9a27 [Doc] Update the docs about attribute() function
2024-12-19 08:40:12 +01:00
Javier Eguiluz 84daad9a27 [Doc] Update the docs about attribute() function 2024-12-19 08:39:55 +01:00
Fabien Potencier f99eab8541 feature #4504 Add a way to stream template rendering (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add a way to stream template rendering

Even if we're using `yield` internally, there is no easy way to stream template rendering. This new method can be used like this to HTTP stream a template with Symfony:

```php
use Symfony\Component\HttpFoundation\StreamedResponse;
use Twig\Environment;

$twig = new Environment(/* ... */);

$response = new StreamedResponse($twig->load('index')->stream([]));
$response->send();
```

Commits
-------

1915ee2812 Add a way to stream template rendering
2024-12-18 19:14:01 +01:00
Fabien Potencier d78cb00f89 Fix doc 2024-12-18 12:19:13 +01:00
Fabien Potencier c13ca48ca5 Use .html.twig in code example instead of .html 2024-12-18 11:13:19 +01:00
Fabien Potencier 834a5a1e5a minor #4507 Use .html.twig file extension in documentation instead of .html (Pepperoni1337)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Use .html.twig file extension in documentation instead of .html

Use .html.twig file extensions instead of .html

Commits
-------

03792f643f Use .html.twig file extension in documentation instead of .html
2024-12-18 11:01:29 +01:00
Pepperoni1337 03792f643f Use .html.twig file extension in documentation instead of .html 2024-12-18 11:01:27 +01:00
Fabien Potencier 2a6c986e85 Add a test 2024-12-18 07:46:55 +01:00
Fabien Potencier 1915ee2812 Add a way to stream template rendering 2024-12-18 07:29:32 +01:00
Fabien Potencier c72b50434d Bump version 2024-12-18 07:29:21 +01:00
Fabien Potencier 918f52e818 feature #4501 adds support for invoking closures (faizanakram99)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

adds support for invoking closures

- fixes #3848

Commits
-------

0a61801d9a adds support for invoking closures
2024-12-14 20:06:36 +01:00
Faizan Akram 0a61801d9a adds support for invoking closures 2024-12-14 20:06:34 +01:00
Fabien Potencier dc2949e88e minor #4502 Change = to : for named arguments (seb-jean)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Change `=` to `:` for named arguments

Hi,
I changed `=` to `:` because it better follows best practices for named arguments.

Commits
-------

99ea35e1e8 Change `=` to `:` for named arguments
2024-12-14 19:49:02 +01:00