Skip to content

Commit 348d260

Browse files
committed
minor #2076 Fix Twig extension return types (smnandre)
This PR was merged into the 2.x branch. Discussion ---------- Fix Twig extension return types Prepare Twig 4.0 compatibility Commits ------- 34d1b75 Fix Twig extension return types
2 parents 15adfa4 + 34d1b75 commit 348d260

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

src/LazyImage/src/Twig/BlurHashExtension.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
*/
2222
class BlurHashExtension extends AbstractExtension
2323
{
24-
public function getFunctions(): iterable
24+
public function getFunctions(): array
2525
{
26-
yield new TwigFunction('data_uri_thumbnail', [BlurHashRuntime::class, 'createDataUriThumbnail']);
27-
yield new TwigFunction('blur_hash', [BlurHashRuntime::class, 'blurHash']);
26+
return [
27+
new TwigFunction('data_uri_thumbnail', [BlurHashRuntime::class, 'createDataUriThumbnail']),
28+
new TwigFunction('blur_hash', [BlurHashRuntime::class, 'blurHash']),
29+
];
2830
}
2931
}

src/Map/src/Twig/MapExtension.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@
2222
*/
2323
final class MapExtension extends AbstractExtension
2424
{
25-
public function getFunctions(): iterable
25+
public function getFunctions(): array
2626
{
27-
yield new TwigFunction('render_map', [Renderers::class, 'renderMap'], [
28-
'is_safe' => ['html'],
29-
'deprecated' => '2.20',
30-
'deprecating_package' => 'symfony/ux-map',
31-
'alternative' => 'ux_map',
32-
]);
33-
yield new TwigFunction('ux_map', [Renderers::class, 'renderMap'], ['is_safe' => ['html']]);
27+
return [
28+
new TwigFunction('render_map', [Renderers::class, 'renderMap'], [
29+
'is_safe' => ['html'],
30+
'deprecated' => '2.21',
31+
'deprecating_package' => 'symfony/ux-map',
32+
'alternative' => 'ux_map',
33+
]),
34+
new TwigFunction('ux_map', [Renderers::class, 'renderMap'], ['is_safe' => ['html']]),
35+
];
3436
}
3537
}

src/Notify/src/Twig/NotifyExtension.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ final class NotifyExtension extends AbstractExtension
2222
/**
2323
* @return iterable<TwigFunction>
2424
*/
25-
public function getFunctions(): iterable
25+
public function getFunctions(): array
2626
{
27-
yield new TwigFunction('stream_notifications', [NotifyRuntime::class, 'renderStreamNotifications'], ['is_safe' => ['html']]);
27+
return [
28+
new TwigFunction('stream_notifications', [NotifyRuntime::class, 'renderStreamNotifications'], ['is_safe' => ['html']]),
29+
];
2830
}
2931
}

src/Turbo/src/Twig/TwigExtension.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ public function __construct(
2727
) {
2828
}
2929

30-
public function getFunctions(): iterable
30+
public function getFunctions(): array
3131
{
32-
yield new TwigFunction('turbo_stream_listen', $this->turboStreamListen(...), ['needs_environment' => true, 'is_safe' => ['html']]);
32+
return [
33+
new TwigFunction('turbo_stream_listen', $this->turboStreamListen(...), ['needs_environment' => true, 'is_safe' => ['html']]),
34+
];
3335
}
3436

3537
/**

0 commit comments

Comments
 (0)