This PR was merged into the 3.x branch.
Discussion
----------
Add throw tag to parse methods
Hi `@fabpot`, with PHPStan improving every day his exception checking, it's useful to have well documented method.
I didn't update all of them (there are too many), and focus on the one I have issue with:
- Almost all the InfixExpressionParserInterface/PrefixExpressionParserInterface implements throws a SyntaxError in parse method
- Parser::parse method is catching SyntaxError and rethrowing them so it should be added to the phpdoc
- Since Parser::parse catch Parser::subparse, it would be useful to add the phpdoc to subparse
Commits
-------
790eee7ae0 Add throw tag to parse methods
This PR was merged into the 3.x branch.
Discussion
----------
Add caution note for random function usage
See https://www.php.net/manual/en/function.array-rand.php and https://www.php.net/manual/en/function.mt-rand.php. Users should know that the Twig function is a convenience feature, but unusable e.g. for serious gaming/gambling apps due to the potential predictability and limited value range.
Commits
-------
02c5a4b0b6 Add caution note for random function usage
This PR was merged into the 3.x branch.
Discussion
----------
Allow Symfony 8 packages in Twig extra packages
I'm testing the upcoming Symfony 8 in some apps, and I have some issues with some Twig extra packages that don't allow installing Symfony 8 packages.
Commits
-------
9a8a1dc1dd Allow Symfony 8 packages in Twig extra packages
This PR was merged into the 3.x branch.
Discussion
----------
Fix array typehint for $variants in HtmlExtension
This PR corrects the array typehint for the `$variants` parameter in the `HtmlExtension::htmlCva` method. It was missing a closing angle bracket (`>`).
Commits
-------
64c87eeaa3 Fix array typehint for $variants in HtmlExtension
This PR was merged into the 3.x branch.
Discussion
----------
Fix accessing arrays with stringable objects as key
Fix#4701
Commits
-------
9ae75d315c Fix accessing arrays with stringable objects as key
This PR was merged into the 3.x branch.
Discussion
----------
[Doc] Tweaks in the escaping article
AS you can see in the redenred page (https://twig.symfony.com/doc/3.x/filters/escape.html) the tip about `html_attr` contains some uneeded line breaks.
This also tweaks another explanation to make it more clear.
Commits
-------
50327b5019 [Doc] Tweaks in the escaping article
This PR was merged into the 3.x branch.
Discussion
----------
Compile 'index' with repr (not string) in EmbedNode
Before this PR, the generated Template code had quotes around the index (integer) parameter value.
Commits
-------
e4d7915702 Compile 'index' with repr (not string) in EmbedNode
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Introduce registerUndefinedTestCallback
This is similar to `registerUndefinedFilterCallback` and `registerUndefinedFunctionCallback`
Commits
-------
cc12df995c Introduce registerUndefinedTestCallback
This PR was merged into the 3.x branch.
Discussion
----------
Fix intl test
Let's try to make it less fragile.
Commits
-------
41bfb6bd8b Fix intl test
This PR was merged into the 3.x branch.
Discussion
----------
Bump minimum Commonmark requirement
All previous versions have security issues
Commits
-------
8f970764e6 Bump minimum Commonmark requirement
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Support two words test guard
Extracted from https://github.com/twigphp/Twig/pull/4687
Commits
-------
30977bdea9 Support two words test guard
This PR was merged into the 3.x branch.
Discussion
----------
Improve documentation examples for `enum` and `enum_cases`
It may be obvious, but I first thought initializing an BackendEnum with a specific value could be possible with `enum(FQCN, value)`, but it does not, it always returns the first case instance (if exists).
Instead, `enum(FQCN).from(value)` must be used, and I think it's worth to improve `enum()` examples.
Commits
-------
def4abbd5e Improve documentation examples for `enum` and `enum_cases`
It may be obvious, but I first thought initializing an BackendEnum with a certain value could be possible with `enum(FQCN, value)`, but it does not, it always returns the first case instance (if exists).
Instead, `enum(FQCN).from(value)` must be used, I think it's worth to improve `enum()` examples.
This PR was merged into the 3.x branch.
Discussion
----------
Avoid errors when failing to guess the template info for an error
Someone reported on the Symfony Slack a case where they get a TypeError in `new \ReflectionObject($template)` in the guessing logic instead of seeing the original error they have (the one for which guessing was attempted), making it impossible to know the original error: https://symfony-devs.slack.com/archives/C01FN4EQNLX/p1756762972076319?thread_ts=1756753204.711889&cid=C01FN4EQNLX
I don't have a reproducer for that case (the original case involve a Symfony form theme, where the form renderer does weird usages of Twig which might lead to the backtrace not containing the expected template).
Not guessing the template file path and the original template line is better than breaking the error reporting.
Commits
-------
62747cee27 Avoid errors when failing to guess the template info for an error
This PR was merged into the 3.x branch.
Discussion
----------
Add note to format_datetime explaining how to install required extensions
Commits
-------
d0177b94cd Add note to format_datetime explaining how to install required extensions
This PR was merged into the 3.x branch.
Discussion
----------
Add missing use statements in ExtensionInterface
Fixes#4677
Note: The classes were used specifically in a ``@psalm`-return` doc statement. But as the repository does not have any psalm config, and does not check it in the CI, this seems to have gone unnoticed for a few months.
Commits
-------
8c78952757#4677: Add use statements for classes referenced in the getOperators `@psalm`-return doc
This PR was merged into the 3.x branch.
Discussion
----------
Allow usage of other Markdown converters than CommonMark in LeagueMarkdown
Since the `CommonMarkConverter` from `League\CommonMark` doesn't allow customizing the `Environment` class at construct-time, this simple change allows providing an instance the parent class, so we can both inject a config to the converter AND a custom list of extensions (like `CommonMarkCoreExtension`) via the constructor.
This PR fixes#3581
Commits
-------
81e66e96bf Update LeagueMarkdown.php
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Escaper performance: avoid static variables
Replace two static variables with `match` expressions.
And bypass a third static variable for the common charset `UTF-8`.
Commits
-------
823f50297b Escaper performance: avoid static variables
This PR was merged into the 3.x branch.
Discussion
----------
Fix compatibility with Symfony 8
Commits
-------
b6a105c952 Fix compatibility with Symfony 8