Commit Graph

7078 Commits

Author SHA1 Message Date
Fabien Potencier b6d9dd62ee Fix inheritance logic to be able to use instanceof ContextVariable instead of NameExpression 2025-01-24 13:47:29 +01:00
Fabien Potencier 72c91f6260 minor #4534 Add return type annotations on Twig 3 to prepare Twig 4 (smnandre)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Add return type annotations on Twig 3 to prepare Twig 4

Started to add missing type annotation following `@stof` comment [here](https://github.com/twigphp/Twig/pull/4523#discussion_r1901915880).

Update:  I checked here every class (but one) in the `src` directory.

But you should ~~probably~~ **certainely** have another look.

Remains:
- src/ExpressionParser.php, where i'm not confident enough about the best return types (AbstractExpression|null works almost everytime, but lack some precision)
- extra directory
- tests directory

I'm happy to let them to someone else.... this was less fun than I expected 😅

Commits
-------

82be13429c Add return type annotations on Twig 3 to prepare Twig 4
2025-01-24 11:33:02 +01:00
Simon André 82be13429c Add return type annotations on Twig 3 to prepare Twig 4 2025-01-24 11:32:59 +01:00
Fabien Potencier 03f6351eb3 minor #4549 Fixing minor typo in inline_css.rst (omarius)
This PR was merged into the 3.x branch.

Discussion
----------

Fixing minor typo in inline_css.rst

The inline_css filter ~inline~ inlines CSS styles in HTML documents:

Commits
-------

498fb5da4c Fixing minor typo in Update inline_css.rst
2025-01-22 14:49:35 +01:00
omarius 498fb5da4c Fixing minor typo in Update inline_css.rst 2025-01-22 13:51:54 +01:00
Fabien Potencier 2b7f280d01 bug #4548 Ignore static properties when using the dot operator (nicolas-grekas)
This PR was merged into the 3.x branch.

Discussion
----------

Ignore static properties when using the dot operator

Fix #4547

Commits
-------

1d5180549f Ignore static properties when using the dot operator
2025-01-22 09:53:24 +01:00
Nicolas Grekas 1d5180549f Ignore static properties when using the dot operator 2025-01-22 09:18:31 +01:00
Fabien Potencier 4f3770ea78 minor #4542 Fix CS (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix CS

Commits
-------

76062c8d51 Fix CS
2025-01-19 17:25:16 +01:00
Fabien Potencier 76062c8d51 Fix CS 2025-01-19 16:54:05 +01:00
Fabien Potencier 6513bc48f0 bug #4541 Fix constant() behavior when used with ?? (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix constant() behavior when used with ??

The fix is broader than just this bug. Basically, it happens when we clone a Node for which an referenced Node will be modified later on.

Commits
-------

a998723b70 Fix constant() behavior when used with ??
2025-01-14 19:59:07 +01:00
Fabien Potencier a998723b70 Fix constant() behavior when used with ?? 2025-01-14 17:55:21 +01:00
Fabien Potencier 65fa0c67f8 feature #4518 Add invoke filter (Lorenz, Lorenzschaef, fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add invoke filter

Adds a new filter `invoke`, to invoke arrow functions and other php callables.

See the discussion here: https://github.com/twigphp/Twig/pull/4378#issuecomment-2557389092

Commits
-------

3e93e91f59 Finish the work
c4fd25fad5 fix indentation
dacbe51b3a Apply suggestions from code review
2b95bd6092 typo
09c30c3ca2 fix merge
d58ac9a1a8 docs and changelog
edecc13f08 typehint instead of checkArrow
f27115857d checkArrow, typehints
8b432758f6 invoke filter
2025-01-12 18:49:25 +01:00
Fabien Potencier 3e93e91f59 Finish the work 2025-01-12 18:48:43 +01:00
Lorenz c4fd25fad5 fix indentation 2025-01-12 18:46:05 +01:00
Lorenz Schäfer dacbe51b3a Apply suggestions from code review
Co-authored-by: Fabien Potencier <fabien@potencier.org>
2025-01-12 18:46:05 +01:00
Lorenz Schäfer 2b95bd6092 typo
Co-authored-by: Christian Flothmann <christian.flothmann@gmail.com>
2025-01-12 18:46:05 +01:00
Lorenz 09c30c3ca2 fix merge 2025-01-12 18:46:05 +01:00
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