Commit Graph

7499 Commits

Author SHA1 Message Date
Fabien Potencier 4b91c31887 Merge branch '3.x' into 4.x
* 3.x:
  Deprecate Twig\ExpressionParser::parseOnlyArguments() and Twig\ExpressionParser::parseArguments()
2025-01-24 14:39:08 +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 a60d639992 Merge branch '3.x' into 4.x
* 3.x:
  Fix inheritance logic to be able to use instanceof ContextVariable instead of NameExpression
2025-01-24 14:11:27 +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 81ca67cdb2 Merge branch '3.x' into 4.x
* 3.x:
  Add return type annotations on Twig 3 to prepare Twig 4
2025-01-24 11:38:08 +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 28246c5d4e Merge branch '3.x' into 4.x
* 3.x:
  Fixing minor typo in Update inline_css.rst
  Ignore static properties when using the dot operator
  Fix CS
  Fix constant() behavior when used with ??
  Finish the work
  fix indentation
  Apply suggestions from code review
  typo
  fix merge
  docs and changelog
  typehint instead of checkArrow
  checkArrow, typehints
  invoke filter
2025-01-24 11:32:17 +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 9bcf837835 Fix test 2025-01-10 08:42:15 +01:00
Fabien Potencier ef7ade8ee3 Merge branch '3.x' into 4.x
* 3.x: (30 commits)
  Make {} optional for the types tag
  Remove the note about types mapping argument
  Add a note on the types locality
  Fix CS
  Fix typos in the docs
  Use spl_object_id() instead of spl_object_hash()
  Add `LastModifiedExtensionInterface` and implementation in `AbstractExtension` to track modification of runtime classes
  Bump version
  Optimize NameExpression compilation
  Fix typo in enum twig doc functions
  Remove dead method in ModuleNode
  Bump version
  Prepare the 3.18.0 release
  Add support for `Twig\Markup`
  Fix unary operator precedence change
  Replace Twigfiddle by the new Twig playground
  Fix MacroNode $name argument can be overridden
  Ignore exceptions from undefined handlers when using the guard tag
  [Doc] Update the docs about attribute() function
  Fix doc
  ...
2025-01-10 08:41:31 +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 cb983da780 minor #4523 Add last missing type hints on Twig4 (smnandre)
This PR was squashed before being merged into the 4.x branch.

Discussion
----------

Add last missing type hints on Twig4

This should be the last batch

Commits
-------

122943c1a1 Add `@return` void on last public methods
24c688693b Type-hint void protected methods of (final) ModuleNode
7eae42183a Add return type on "__toString" methods
2025-01-02 09:46:22 +01:00
Fabien Potencier 0e6f87809e minor #4522 Add @template on RuntimeLoaderinterface (Twig 4) (smnandre)
This PR was merged into the 4.x branch.

Discussion
----------

Add `@template` on RuntimeLoaderinterface (Twig 4)

Do php-stan annotation have an impact on BC promise?

The interface uses the term "class" already.. i'm guessing it's ok ?

Commits
-------

c24c71a3ca Add `@template` on RuntimeLoaderinterface (Twig 4)
2025-01-02 09:45:15 +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