This PR was merged into the 3.x branch.
Discussion
----------
Skip the property checker call and memoize the class constant probe when reading an object attribute
Commits
-------
ddd9045b5c Skip the property checker call and memoize the class constant probe when reading an object attribute
This PR was merged into the 3.x branch.
Discussion
----------
Stop looking up a macro twice in its own namespace when it is declared by a parent
Commits
-------
e3f0d6fb4c Stop looking up a macro twice in its own namespace when it is declared by a parent
This PR was merged into the 3.x branch.
Discussion
----------
Fetch the escaper runtime once in the constructor of templates that escape
Commits
-------
3417f483bf Fetch the escaper runtime once in the constructor of templates that escape
This PR was merged into the 3.x branch.
Discussion
----------
Compare the date formatter prototype pattern with the derived one once per pattern
Commits
-------
10fe9808bb Compare the date formatter prototype pattern with the derived one once per pattern
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Fix split trailing newline
Commits
-------
00861d50ab Fix split trailing newline
This PR was merged into the 3.x branch.
Discussion
----------
Speed up adding extensions to an environment
`Environment::addExtension()` recomputes the options hash on every call, JSON-encoding the class names of all the extensions registered so far. This computes it only when a template class name is needed. With the 24 extensions TwigBundle registers on the Symfony Demo, building the environment drops from 87µs to 19µs, and calling `setExtensions()` once instead brings nothing more.
Merge-up to 4.x: the property is typed there, so it has to become `private ?string $optionsHash = null;` (I ran the 4.x suite with that change). The CHANGELOG entry doesn't go to 4.x.
Commits
-------
d3d13f9b1a Speed up adding extensions to an environment
This PR was merged into the 3.x branch.
Discussion
----------
Reuse the already resolved callable when compiling call arguments
Commits
-------
16be8af8f5 Reuse the already resolved callable when compiling call arguments
This PR was merged into the 3.x branch.
Discussion
----------
Compile the generator guard as an unreachable yield instead of a yield from
Commits
-------
4d5d233776 Compile the generator guard as an unreachable yield instead of a yield from
This PR was merged into the 3.x branch.
Discussion
----------
Speed up loading a template that the environment has already loaded
`Environment::load()` allocated a fresh `TemplateWrapper` on every call, even when the template was already loaded. Since `TemplateWrapper` is immutable, the same instance can be reused.
**Performance** (PHP 8.5, interleaved A/B, min of 5 runs):
| Workload | Before | After | |
|---|---:|---:|---:|
| Repeated `load()` of a loaded template | ~800 ns | ~610 ns | **−24%** |
| Page render: layout + 41 `include()` calls | 133 µs | 127 µs | **−5%** |
Commits
-------
6f94a47ce1 Reuse the template wrapper of an already loaded template
This PR was merged into the 3.x branch.
Discussion
----------
Stop the escaping safe analysis from retaining every analyzed node
Commits
-------
8274571d04 Stop the escaping safe analysis from retaining every analyzed node
This PR was merged into the 3.x branch.
Discussion
----------
Allow to call `TemplateWrapper::unwrap()` without arguments
Fixes#4935, symfony/symfony#66193.
#4910 changed an internal API that has famously been used by Symfony since almost forever. We would now need to change Symfony's 5.4 branch which is security-only. Because of that, I'd like to propose to allow calling `TemplateWrapper::unwrap()` without parameters again. This should allow running Symfony 5.4 with the latest Twig 3 again.
We can revert my change on the 4.x branch.
Commits
-------
bfbe89e3a3 Allow to call TemplateWrapper::unwrap() without arguments
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Expose the escaping strategy a template was compiled with
Compiled templates now record the escaping strategy they were compiled with and expose it via `TemplateWrapper::getDefaultEscapeStrategy()`, so the strategy of a template can be known without deriving it again from its name, which is both slower and can disagree with how its content was actually escaped.
Commits
-------
26812ebc0d Expose the escaping strategy a template was compiled with
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Improve macro call performance
This is mostly about getting back to the same performance we had in 3.28.
Commits
-------
a8ee6dd762 Improve macro call performance
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Fix IntlExtension inheriting values derived by ICU from a date formatter prototype
Commits
-------
6671288259 Fix IntlExtension inheriting values derived by ICU from a date formatter prototype
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Fix array access with a Stringable key on subclasses of ArrayObject and ArrayIterator
Commits
-------
4aae99e92c Fix array access with a Stringable key on subclasses of ArrayObject and ArrayIterator
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Report a clear error when a string cannot be split into characters
Commits
-------
1ee9dae55a Cover and document the matches operator throwing on an invalid UTF-8 subject
5c1be030c5 Report a clear error when a string cannot be split into characters
This PR was merged into the 3.x branch.
Discussion
----------
Deprecate cloning a Twig environment
Commits
-------
55afb2e084 Deprecate cloning a Twig environment
This PR was merged into the 3.x branch.
Discussion
----------
Report the macro call parentheses deprecation once per call site and name the macro
Commits
-------
40d57c6445 Report the macro call parentheses deprecation once per call site and name the macro
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Reject template wrappers from another environment
Twig now rejects `TemplateWrapper` instances created by another `Environment`.
This prevents templates from unexpectedly using another environment's loader, extensions, globals, or sandbox policy.
Commits
-------
83e8f7e123 Reject cross-environment template wrappers in block chains
c1fc112047 Reject cross-environment template wrappers
This PR was merged into the 3.x branch.
Discussion
----------
Report a clear error when using macros imported in a template body that was not rendered
Commits
-------
72c2f669bd Report a clear error when using macros imported in a template body that was not rendered