This PR was squashed before being merged into the 4.x branch.
Discussion
----------
[Twig 4] Add PHPUnit as dev dependency
This makes it easier to run the tests locally.
I understand we didn't do this previously (Twig 3) because of `symfony/simple-phpunit`. But that is now removed in Twig 4, so maybe we can do this as well?
Commits
-------
c352a8d283 [Twig 4] Add PHPUnit as dev dependency
This PR was merged into the 3.x branch.
Discussion
----------
Use [] instead of array() to represent a constant value in compiled code
Commits
-------
49f384f107 Use [] instead of array() to represent a constant value in compiled code
This PR was merged into the 3.x branch.
Discussion
----------
Enforce AbstractBinary for all binary operators
Commits
-------
4f8ba93600 Enforce AbstractBinary for all binary operators
This PR was merged into the 3.x branch.
Discussion
----------
Simplify code even more
More simplifications
Commits
-------
2337c7f812 Simplify code even more
This PR was merged into the 3.x branch.
Discussion
----------
Simplify EscaperNodeVisitor code
This PR simplifies how we escape the ternary operator, and simplifies the whole strategy.
Instead of replacing the `PrintNode`s, we instead "just" wrap the inner expressions.
For the ternary operator, the `InlinePrint` expression is useless and even weird as printing something in the middle of an expression looks very wrong. This is not done anymore and the node is deprecated.
Overall, this PR makes fewer changes to the Node tree which should make things use a bit less memory.
Commits
-------
02cec77619 Simplify EscaperNodeVisitor code
This PR was merged into the 3.x branch.
Discussion
----------
Fix having macro variables starting with an underscore
Closes#4452
Commits
-------
bdb0f3c042 Fix having macro variables starting with an underscore
This PR was merged into the 3.x branch.
Discussion
----------
Fix SafeAnalysisNodeVisitor::getSafe() return value
`SafeAnalysisNodeVisitor::getSafe()` can return `[]` or `null`. Both mean the same thing, but `null` is partially supported as `EscaperNodeVisitor` does not support `null` everywhere (as the node visitor never set `safe` to `null`). But a third party might return `null`. This PR makes the code more robust by deprecating using `null`.
Commits
-------
c402debcb8 Fix EscapeNodeVisitor::isSafeFor()
This PR was merged into the 3.x branch.
Discussion
----------
Simplify code
The current "optimizes" the generated code when possible, but it's probably useless (and removing the code makes compilation a bit faster):
```php
// Before
yield ((a) ? ("a") : ("b"));
// After
((a) ? (yield "a") : (yield "b"));
```
Commits
-------
e39a7af56e Simplify code
This PR was merged into the 3.x branch.
Discussion
----------
Deprecate not passing a Source to TokenStream
Closes#4457
Commits
-------
e7e72ff090 Deprecate not passing a Source to TokenStream
This PR was merged into the 4.x branch.
Discussion
----------
Remove PHP 8.1 polyfill
Not needed when the Twig 4 requires 8.2.
Commits
-------
077d7a54b6 Remove PHP 8.1 polyfill
This PR was merged into the 3.x branch.
Discussion
----------
Specify allow round methods
This way, PHPStan can validate invalid input.
Commits
-------
fb43e7a854 Specify allow round methods