This PR was merged into the 3.x branch.
Discussion
----------
Fix intl-extra tests
Fix CI since `Scripts::getNames()` returns 4 new values. It just tests if the value is an array to limit maintenance on future updates.
Commits
-------
683adc550f Fix intl-extra tests
This PR was merged into the 3.x branch.
Discussion
----------
Fix tiny typo in CI step name
Just a nano-typo there in a step name
`symfony/translation-contract`+`s`
Commits
-------
949f351458 Fix tiny typo in CI workflow label
This PR was merged into the 3.x branch.
Discussion
----------
Fix opcache preload warning for unlinked anonymous class
This fixes PHP opcache preload warning, caused by https://github.com/php/php-src/issues/10131 . The warning is now produced when the preload is initiated.
> Can't preload unlinked class Twig\ExpressionParser\Infix\BinaryOperatorExpressionParser@anonymous: Unknown parent Twig\ExpressionParser\Infix\BinaryOperatorExpressionParser
This started with Twig 3.21, when the anonymous class started to be used in ExtensionSet.
This is a similar woraround as is already used in a TwigBridge, as suggested by `@nicolas`-grekas here https://github.com/symfony/symfony/pull/38533
Also similar fix is in API platform: https://github.com/api-platform/core/pull/3827
Commits
-------
86997d1bef Fix opcache preload warning for unlinked anonymous class
This PR was merged into the 3.x branch.
Discussion
----------
Add .gitignore & .gitattributes to all .gitattributes
Commits
-------
ff327e4163 Add .gitignore & .gitattributes to all .gitattributes
This PR was merged into the 3.x branch.
Discussion
----------
Avoid ord deprecation notice in PHP 8.5
Change the one usage of `ord()` in Twig where a multibyte character can trigger the new deprecation in PHP 8.5, which is in the `html_attr` escape functionality in EscaperRuntime, currently leading to:
```
ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead"
```
This small change fixes it. There are no other usages of `ord()` in Twig which lead to this deprecation notice.
Commits
-------
4d98cce4e4 Avoid ord deprecation in PHP 8.5
Change the one usage of ord() in Twig where a multibyte character can trigger the new deprecation in PHP 8.5, which is in the `html_attr` escape functionality, previously leading to:
ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead"
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
use getShareDir as an indicator of Symfony version
Proposal to fix#4719 , replaces #4721
Commits
-------
c4dcd0bb8c use getShareDir as an indicator of Symfony version
This PR was merged into the 3.x branch.
Discussion
----------
Add 'invoke' to filters index
Missing from https://github.com/twigphp/Twig/pull/4518 I think.
Commits
-------
f7daf71acc Add 'invoke' to filters index
This PR was merged into the 3.x branch.
Discussion
----------
Fix cycle() with non-countable ArrayAccess+Traversable objects
When using `cycle()` with an object that implements `\ArrayAccess` and `\Traversable` but is not `\Countable`, the function currently returns the object instance immediately after triggering the deprecation notice.
This prevents the value from being converted to an array, causing the cycle logic to fail or return the object itself.
This PR removes the early return to ensure `self::toArray()` is called, allowing these objects to be cycled correctly as expected.
**How to test**
```php
$seq = new class implements \ArrayAccess, \IteratorAggregate {
public function offsetExists($offset): bool { return true; }
public function offsetGet($offset): mixed { return 'val'; }
public function offsetSet($offset, $value): void {}
public function offsetUnset($offset): void {}
public function getIterator(): \Traversable { yield 'odd'; yield 'even'; }
};
// Should return 'odd', currently returns the $seq object
$result = CoreExtension::cycle($seq, 0);
```
Related to #4241
Commits
-------
473653d19b [Core] Fix cycle() with non-countable ArrayAccess+Traversable objects
This PR was merged into the 3.x branch.
Discussion
----------
Update .gitattributes to exclude phpstan configs
They where added in https://github.com/twigphp/Twig/pull/4458
Versions >= 3.16.0 have the not needed files
Commits
-------
2e0c874776 Update .gitattributes to exclude phpstan configs
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
`CoreExtension` : Make error message more readable
It's a silly little patch, but really improves the readability of the error message IMO ...
Commits
-------
40248e4ca9 `CoreExtension` : Make error message more readable
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