Deprecate calling TemplateWrapper::unwrap() without arguments as of 3.30 and list the fix in the CHANGELOG

This commit is contained in:
Fabien Potencier
2026-09-25 07:33:53 +02:00
parent 9c3d58e638
commit c8d782ea0b
3 changed files with 3 additions and 2 deletions
+1
View File
@@ -8,6 +8,7 @@
* Fix `IntlExtension` letting the pattern derived from a date formatter prototype override an explicit locale
* Fix `IntlExtension` not honoring the locale of a date formatter prototype configured with no date and time styles
* Speed up macro calls
* Fix `TemplateWrapper::unwrap()` failing when called without arguments, which is now deprecated
* Add `TemplateWrapper::getDefaultEscapeStrategy()` to know the escaping strategy a template was compiled with
* Report a clear error when `random`, `reverse`, `shuffle`, and `split` receive a string that is not valid UTF-8
* Fix the deprecation about omitting parentheses when calling a macro being reported twice for the same call
+1 -1
View File
@@ -124,7 +124,7 @@ final class TemplateWrapper
public function unwrap(?Environment $env = null): Template
{
if (null === $env) {
trigger_deprecation('twig/twig', '3.29', 'Calling "%s()" without arguments is deprecated, pass the Twig environment instead.', __METHOD__);
trigger_deprecation('twig/twig', '3.30', 'Calling "%s()" without arguments is deprecated, pass the Twig environment instead.', __METHOD__);
} elseif (!$this->isOwnedBy($env)) {
throw new RuntimeError(\sprintf('A "%s" can only be used with the "%s" that created it.', self::class, Environment::class));
}
+1 -1
View File
@@ -56,7 +56,7 @@ class TemplateWrapperTest extends TestCase
$twig = new Environment(new ArrayLoader(['index' => 'content']));
$wrapper = $twig->load('index');
$this->expectDeprecation('Since twig/twig 3.29: Calling "Twig\TemplateWrapper::unwrap()" without arguments is deprecated, pass the Twig environment instead.');
$this->expectDeprecation('Since twig/twig 3.30: Calling "Twig\TemplateWrapper::unwrap()" without arguments is deprecated, pass the Twig environment instead.');
$this->assertInstanceOf(Template::class, $wrapper->unwrap());
}