Commit Graph

8393 Commits

Author SHA1 Message Date
Fabien Potencier 7e178be4e5 tidy #4969 Fix the CHANGELOG entry about Environment::getGlobals() (fabpot)
This PR was merged into the 4.x branch.

Discussion
----------

Fix the CHANGELOG entry about Environment::getGlobals()

Commits
-------

eb5687a248 Fix the CHANGELOG entry about Environment::getGlobals()
2026-09-26 10:37:48 +02:00
Fabien Potencier b201be0afd tidy #4957 4.x cleanup (fabpot)
This PR was squashed before being merged into the 4.x branch.

Discussion
----------

4.x cleanup

Commits
-------

4493d0747a Merge the CHANGELOG entries about the inert attributes
2a16651387 Explain that the inert attribute classes are kept for static analysis, not class loading
991294ae39 Drop the 3.x version from the SandboxExtension internal annotation
69a4e43f0a Remove the inert FirstClassTwigCallableReady attribute from the built-in nodes
bb0dbfc229 Stop passing the template source to the sandbox checks that no longer use it
a5abf30b19 Remove the deprecation getters from TwigCallableInterface
dbfd06ffba Make Markup final
40b0349558 Run the attribute function fixtures as regular integration tests
6b7dfe3dcc Remove outdated references to older Twig versions
ea98cfa8c8 Remove the static test container fallback from the extra bundle integration test
57ef149e3b Remove the League CommonMark fallback for converters without convert()
2026-09-26 10:37:23 +02:00
Fabien Potencier 4882f353ed tidy #4968 Remove the opcache preload hint for a class ExtensionSet no longer extends (fabpot)
This PR was merged into the 4.x branch.

Discussion
----------

Remove the opcache preload hint for a class ExtensionSet no longer extends

Commits
-------

221e5eaa8c Remove the opcache preload hint for a class ExtensionSet no longer extends
2026-09-26 10:35:52 +02:00
Fabien Potencier 674f7d84ef Merge branch '3.x' into 4.x 2026-09-26 10:26:14 +02:00
Fabien Potencier e0af798ea9 minor #4965 Rewrite the sandbox documentation around what developers need to know (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Rewrite the sandbox documentation around what developers need to know

Commits
-------

9d24327f8d Rewrite the sandbox documentation around what developers need to know
2026-09-26 10:23:05 +02:00
Fabien Potencier 9d24327f8d Rewrite the sandbox documentation around what developers need to know 2026-09-26 10:02:08 +02:00
Fabien Potencier eb5687a248 Fix the CHANGELOG entry about Environment::getGlobals() 2026-09-26 09:34:23 +02:00
Fabien Potencier 221e5eaa8c Remove the opcache preload hint for a class ExtensionSet no longer extends 2026-09-26 09:34:10 +02:00
Fabien Potencier 4493d0747a Merge the CHANGELOG entries about the inert attributes 2026-09-26 08:09:27 +02:00
Fabien Potencier 2a16651387 Explain that the inert attribute classes are kept for static analysis, not class loading 2026-09-26 08:07:31 +02:00
Fabien Potencier 991294ae39 Drop the 3.x version from the SandboxExtension internal annotation 2026-09-25 23:52:43 +02:00
Fabien Potencier 69a4e43f0a Remove the inert FirstClassTwigCallableReady attribute from the built-in nodes 2026-09-25 23:52:28 +02:00
Fabien Potencier bb0dbfc229 Stop passing the template source to the sandbox checks that no longer use it 2026-09-25 23:52:13 +02:00
Fabien Potencier a5abf30b19 Remove the deprecation getters from TwigCallableInterface 2026-09-25 23:51:40 +02:00
Fabien Potencier dbfd06ffba Make Markup final 2026-09-25 23:51:14 +02:00
Fabien Potencier 40b0349558 Run the attribute function fixtures as regular integration tests 2026-09-25 23:31:09 +02:00
Fabien Potencier 6b7dfe3dcc Remove outdated references to older Twig versions 2026-09-25 23:31:09 +02:00
Fabien Potencier ea98cfa8c8 Remove the static test container fallback from the extra bundle integration test 2026-09-25 23:31:09 +02:00
Fabien Potencier 57ef149e3b Remove the League CommonMark fallback for converters without convert() 2026-09-25 23:31:09 +02:00
Fabien Potencier 07b8427e26 Merge branch '3.x' into 4.x 2026-09-25 18:04:23 +02:00
Fabien Potencier 2904612341 minor #4949 Skip the property checker call and memoize the class constant probe when reading an object attribute (fabpot)
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
2026-09-25 16:01:04 +02:00
Fabien Potencier ddd9045b5c Skip the property checker call and memoize the class constant probe when reading an object attribute 2026-09-25 16:00:51 +02:00
Fabien Potencier cbcfe403a0 bug #4947 Stop looking up a macro twice in its own namespace when it is declared by a parent (fabpot)
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
2026-09-25 15:50:23 +02:00
Fabien Potencier 2558df70b6 Bump version 2026-09-25 15:20:29 +02:00
Fabien Potencier 8c737079b7 Prepare the 3.30.0 release v3.30.0 2026-09-25 15:20:01 +02:00
Fabien Potencier 052c7efdde minor #4950 Fetch the escaper runtime once in the constructor of templates that escape (fabpot)
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
2026-09-25 12:45:04 +02:00
Fabien Potencier 3417f483bf Fetch the escaper runtime once in the constructor of templates that escape 2026-09-25 12:44:56 +02:00
Fabien Potencier 9e198d7637 minor #4948 Compare the date formatter prototype pattern with the derived one once per pattern (fabpot)
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
2026-09-25 12:41:20 +02:00
Fabien Potencier 22e31198e7 bug #4946 Fix split trailing newline (fabpot)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Fix split trailing newline

Commits
-------

00861d50ab Fix split trailing newline
2026-09-25 12:39:42 +02:00
Fabien Potencier 00861d50ab Fix split trailing newline 2026-09-25 12:39:38 +02:00
Fabien Potencier 81cc196cae Bump version 2026-09-25 07:50:37 +02:00
Fabien Potencier e3f0d6fb4c Stop looking up a macro twice in its own namespace when it is declared by a parent 2026-09-25 07:50:11 +02:00
Fabien Potencier 10fe9808bb Compare the date formatter prototype pattern with the derived one once per pattern 2026-09-25 07:50:11 +02:00
Fabien Potencier c8d782ea0b Deprecate calling TemplateWrapper::unwrap() without arguments as of 3.30 and list the fix in the CHANGELOG 2026-09-25 07:44:32 +02:00
Fabien Potencier 9c3d58e638 Fix coding standards 2026-09-25 07:44:12 +02:00
Fabien Potencier 4d073d938a Drop a comment restating the code and clarify the fully named macro call fast path 2026-09-25 07:44:00 +02:00
Fabien Potencier 9d33a10324 minor #4945 Speed up adding extensions to an environment (nicolas-grekas)
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
2026-09-24 19:20:19 +02:00
Nicolas Grekas d3d13f9b1a Speed up adding extensions to an environment 2026-09-24 18:47:14 +02:00
Fabien Potencier cc16fa8991 feature #4941 Cleanup 4.x - Stop detecting echo and print in compiled nodes (fabpot)
This PR was squashed before being merged into the 4.x branch.

Discussion
----------

Cleanup 4.x - Stop detecting echo and print in compiled nodes

Commits
-------

3c89f82d4a Cleanup 4.x - Stop detecting echo and print in compiled nodes
2026-09-23 10:50:32 +01:00
Fabien Potencier 3c89f82d4a Cleanup 4.x - Stop detecting echo and print in compiled nodes 2026-09-23 10:50:26 +01:00
Fabien Potencier efa368c8d7 minor #4940 Reuse the already resolved callable when compiling call arguments (fabpot)
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
2026-09-23 07:18:00 +01:00
Fabien Potencier 16be8af8f5 Reuse the already resolved callable when compiling call arguments 2026-09-23 07:17:53 +01:00
Fabien Potencier 154ae335bb minor #4939 Compile the generator guard as an unreachable yield instead of a yield from (fabpot)
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
2026-09-23 07:16:36 +01:00
Fabien Potencier 4d5d233776 Compile the generator guard as an unreachable yield instead of a yield from 2026-09-22 22:00:07 +01:00
Fabien Potencier 10adb67bcf Remove deprecated code 2026-09-22 21:17:13 +01:00
Fabien Potencier a38543b5a3 Fix merge conflict resolution 2026-09-22 21:14:25 +01:00
Fabien Potencier f3bacf3877 Merge branch '3.x' into 4.x
* 3.x:
  Reuse the template wrapper of an already loaded template
  Stop the escaping safe analysis from retaining every analyzed node
  Allow to call TemplateWrapper::unwrap() without arguments
  Expose the escaping strategy a template was compiled with
  Improve macro call performance
  Fix IntlExtension inheriting values derived by ICU from a date formatter prototype
  Fix array access with a Stringable key on subclasses of ArrayObject and ArrayIterator
  Ignore the PHPUnit 10+ cache directory
  Cover and document the matches operator throwing on an invalid UTF-8 subject
  Report a clear error when a string cannot be split into characters
  Deprecate cloning a Twig environment
  Report the macro call parentheses deprecation once per call site and name the macro
  Bump version
  Prepare the 3.29.0 release
  Update CHANGELOG

# Conflicts:
#	.gitignore
#	CHANGELOG
#	doc/deprecated.rst
#	src/Environment.php
#	src/NodeVisitor/CorrectnessNodeVisitor.php
#	src/NodeVisitor/SafeAnalysisNodeVisitor.php
#	src/Template.php
#	tests/Fixtures/macros/call_without_parentheses.legacy.test
#	tests/ParserTest.php
#	tests/TemplateTest.php
#	tests/TwigMacroTest.php
2026-09-22 21:10:53 +01:00
Fabien Potencier c33dd1c473 feature #4938 Speed up loading a template that the environment has already loaded (fabpot)
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
2026-09-22 21:03:17 +01:00
Fabien Potencier 6f94a47ce1 Reuse the template wrapper of an already loaded template 2026-09-22 21:02:38 +01:00
Fabien Potencier ff4a1c6575 bug #4937 Stop the escaping safe analysis from retaining every analyzed node (fabpot)
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
2026-09-22 20:42:55 +01:00