Commit Graph

7089 Commits

Author SHA1 Message Date
Fabien Potencier d76d2d7d26 minor #4555 add missing parentheses to deprecation message (xabbuh)
This PR was merged into the 3.x branch.

Discussion
----------

add missing parentheses to deprecation message

Commits
-------

431697fc05 add missing parentheses to deprecation message
2025-01-24 21:36:20 +01:00
Christian Flothmann 431697fc05 add missing parentheses to deprecation message 2025-01-24 20:59:56 +01:00
Fabien Potencier 939c0324c7 feature #4554 Deprecate Token::getType() (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate Token::getType()

This change will allow us to deprecate some types and let us trigger a deprecation.

Commits
-------

ade8bce516 Deprecate Token::getType()
2025-01-24 15:50:48 +01:00
Fabien Potencier ade8bce516 Deprecate Token::getType() 2025-01-24 15:48:04 +01:00
Fabien Potencier c542debe58 feature #4553 Add ForElseNode (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add ForElseNode

Replaces #4473 for 3.x

Commits
-------

609767522a Add ForElseNode
2025-01-24 15:29:49 +01:00
Fabien Potencier 609767522a Add ForElseNode 2025-01-24 15:25:30 +01:00
Fabien Potencier 17b35c80fa feature #4552 Deprecate passing $ifexpr to ForNode (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate passing $ifexpr to ForNode

Commits
-------

9d16de6e3d Deprecate passing $ifexpr to ForNode
2025-01-24 15:07:44 +01:00
Fabien Potencier 9d16de6e3d Deprecate passing $ifexpr to ForNode 2025-01-24 15:01:34 +01:00
Fabien Potencier 93466404b7 feature #4550 Deprecate Twig\ExpressionParser::parseOnlyArguments() and Twig\ExpressionParser::parseArguments() (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate Twig\ExpressionParser::parseOnlyArguments() and Twig\ExpressionParser::parseArguments()

Commits
-------

960f6762ed Deprecate Twig\ExpressionParser::parseOnlyArguments() and Twig\ExpressionParser::parseArguments()
2025-01-24 14:36:45 +01:00
Fabien Potencier ce40c69bc7 feature #4551 Fix inheritance logic to be able to use instanceof ContextVariable instead of NameExpression (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix inheritance logic to be able to use instanceof ContextVariable instead of NameExpression

Commits
-------

b6d9dd62ee Fix inheritance logic to be able to use instanceof ContextVariable instead of NameExpression
2025-01-24 14:09:02 +01:00
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 960f6762ed Deprecate Twig\ExpressionParser::parseOnlyArguments() and Twig\ExpressionParser::parseArguments() 2025-01-23 08:35:56 +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