Skip to content

Commit ec77d94

Browse files
committed
minor symfony#52741 [TwigBridge][TwigBundle][VarDumper] Remove legacy Twig_ namespace support (GromNaN)
This PR was merged into the 7.0 branch. Discussion ---------- [TwigBridge][TwigBundle][VarDumper] Remove legacy Twig_ namespace support | Q | A | ------------- | --- | Branch? | 7.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Twig 3.0 is required by Symfony 7.0+, support for legacy class names is not necessary. Nothing added to TwigBundle changelog as "Drop support for Twig 2" is already mentionned. For VarDumper, since there is no version constraint for `twig/twig`, I added a line to the changelog. Commits ------- 6b8fad9 Remove legacy Twig_ namespace support
2 parents 04e6833 + 6b8fad9 commit ec77d94

File tree

5 files changed

+4
-9
lines changed

5 files changed

+4
-9
lines changed

src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function getHtmlCallGraph(): Markup
131131

132132
public function getProfile(): Profile
133133
{
134-
return $this->profile ??= unserialize($this->data['profile'], ['allowed_classes' => ['Twig_Profiler_Profile', Profile::class]]);
134+
return $this->profile ??= unserialize($this->data['profile'], ['allowed_classes' => [Profile::class]]);
135135
}
136136

137137
private function getComputedData(string $index): mixed

src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ protected function getVariableGetterWithoutStrictCheck($name)
5050

5151
protected function getVariableGetterWithStrictCheck($name)
5252
{
53-
if (Environment::MAJOR_VERSION >= 2) {
54-
return sprintf('(isset($context["%1$s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new %2$s(\'Variable "%1$s" does not exist.\', 0, $this->source); })())', $name, Environment::VERSION_ID >= 20700 ? 'RuntimeError' : 'Twig_Error_Runtime');
55-
}
56-
57-
return sprintf('($context["%s"] ?? $this->getContext($context, "%1$s"))', $name);
53+
return sprintf('(isset($context["%1$s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new RuntimeError(\'Variable "%1$s" does not exist.\', 0, $this->source); })())', $name);
5854
}
5955
}

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ public function load(array $configs, ContainerBuilder $container): void
170170
'optimizations' => true,
171171
]));
172172

173-
$container->registerForAutoconfiguration(\Twig_ExtensionInterface::class)->addTag('twig.extension');
174-
$container->registerForAutoconfiguration(\Twig_LoaderInterface::class)->addTag('twig.loader');
175173
$container->registerForAutoconfiguration(ExtensionInterface::class)->addTag('twig.extension');
176174
$container->registerForAutoconfiguration(LoaderInterface::class)->addTag('twig.loader');
177175
$container->registerForAutoconfiguration(RuntimeExtensionInterface::class)->addTag('twig.runtime');

src/Symfony/Component/VarDumper/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* Add argument `$label` to `VarDumper::dump()`
88
* Require explicit argument when calling `VarDumper::setHandler()`
9+
* Remove display of backtrace in `Twig_Template`, only `Twig\Template` are supported
910

1011
6.4
1112
---

src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, boo
214214
$ellipsis = $ellipsis->attr['ellipsis'] ?? 0;
215215

216216
if (is_file($f['file']) && 0 <= self::$srcContext) {
217-
if (!empty($f['class']) && (is_subclass_of($f['class'], 'Twig\Template') || is_subclass_of($f['class'], 'Twig_Template')) && method_exists($f['class'], 'getDebugInfo')) {
217+
if (!empty($f['class']) && is_subclass_of($f['class'], 'Twig\Template') && method_exists($f['class'], 'getDebugInfo')) {
218218
$template = null;
219219
if (isset($f['object'])) {
220220
$template = $f['object'];

0 commit comments

Comments
 (0)