Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 04ee49a

Browse filesBrowse files
committed
bug #54800 [WebProfilerBundle] fix compatibility with Twig 3.10 (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [WebProfilerBundle] fix compatibility with Twig 3.10 | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT see twigphp/Twig#4055 Commits ------- a4190b5 fix compatibility with Twig 3.10
2 parents c5e56bb + a4190b5 commit 04ee49a
Copy full SHA for 04ee49a

File tree

Expand file treeCollapse file tree

2 files changed

+9
-10
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-10
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php
+2-10Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bundle\WebProfilerBundle\Twig\WebProfilerExtension;
1616
use Symfony\Component\VarDumper\Cloner\VarCloner;
1717
use Twig\Environment;
18+
use Twig\Loader\ArrayLoader;
1819

1920
class WebProfilerExtensionTest extends TestCase
2021
{
@@ -23,7 +24,7 @@ class WebProfilerExtensionTest extends TestCase
2324
*/
2425
public function testDumpHeaderIsDisplayed(string $message, array $context, bool $dump1HasHeader, bool $dump2HasHeader)
2526
{
26-
$twigEnvironment = $this->mockTwigEnvironment();
27+
$twigEnvironment = new Environment(new ArrayLoader());
2728
$varCloner = new VarCloner();
2829

2930
$webProfilerExtension = new WebProfilerExtension();
@@ -44,13 +45,4 @@ public static function provideMessages(): iterable
4445
yield ['Some message {foo}', ['foo' => 'foo', 'bar' => 'bar'], true, false];
4546
yield ['Some message {foo}', ['bar' => 'bar'], false, true];
4647
}
47-
48-
private function mockTwigEnvironment()
49-
{
50-
$twigEnvironment = $this->createMock(Environment::class);
51-
52-
$twigEnvironment->expects($this->any())->method('getCharset')->willReturn('UTF-8');
53-
54-
return $twigEnvironment;
55-
}
5648
}

‎src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Twig\Extension\EscaperExtension;
1818
use Twig\Extension\ProfilerExtension;
1919
use Twig\Profiler\Profile;
20+
use Twig\Runtime\EscaperRuntime;
2021
use Twig\TwigFunction;
2122

2223
/**
@@ -114,6 +115,12 @@ public function getName()
114115

115116
private static function escape(Environment $env, string $s): string
116117
{
118+
// Twig 3.10 and above
119+
if (class_exists(EscaperRuntime::class)) {
120+
return $env->getRuntime(EscaperRuntime::class)->escape($s);
121+
}
122+
123+
// Twig 3.9
117124
if (method_exists(EscaperExtension::class, 'escape')) {
118125
return EscaperExtension::escape($env, $s);
119126
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.