From c42b96451d8f00e2b00810fd71f627a0a9bb39a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Sat, 17 Aug 2024 23:42:29 +0200 Subject: [PATCH] Fix Twig extension return types Prepare Twig 4.0 compatibility --- src/LazyImage/src/Twig/BlurHashExtension.php | 8 +++++--- src/Map/src/Twig/MapExtension.php | 6 ++++-- src/Notify/src/Twig/NotifyExtension.php | 6 ++++-- src/Turbo/src/Twig/TwigExtension.php | 6 ++++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/LazyImage/src/Twig/BlurHashExtension.php b/src/LazyImage/src/Twig/BlurHashExtension.php index cd872ecbc66..5ac2f3b520f 100644 --- a/src/LazyImage/src/Twig/BlurHashExtension.php +++ b/src/LazyImage/src/Twig/BlurHashExtension.php @@ -21,9 +21,11 @@ */ class BlurHashExtension extends AbstractExtension { - public function getFunctions(): iterable + public function getFunctions(): array { - yield new TwigFunction('data_uri_thumbnail', [BlurHashRuntime::class, 'createDataUriThumbnail']); - yield new TwigFunction('blur_hash', [BlurHashRuntime::class, 'blurHash']); + return [ + new TwigFunction('data_uri_thumbnail', [BlurHashRuntime::class, 'createDataUriThumbnail']), + new TwigFunction('blur_hash', [BlurHashRuntime::class, 'blurHash']), + ]; } } diff --git a/src/Map/src/Twig/MapExtension.php b/src/Map/src/Twig/MapExtension.php index b55e5de562d..6112c808446 100644 --- a/src/Map/src/Twig/MapExtension.php +++ b/src/Map/src/Twig/MapExtension.php @@ -22,8 +22,10 @@ */ final class MapExtension extends AbstractExtension { - public function getFunctions(): iterable + public function getFunctions(): array { - yield new TwigFunction('render_map', [Renderers::class, 'renderMap'], ['is_safe' => ['html']]); + return [ + new TwigFunction('render_map', [Renderers::class, 'renderMap'], ['is_safe' => ['html']]), + ]; } } diff --git a/src/Notify/src/Twig/NotifyExtension.php b/src/Notify/src/Twig/NotifyExtension.php index bd2204aef31..0ddb44bf27e 100644 --- a/src/Notify/src/Twig/NotifyExtension.php +++ b/src/Notify/src/Twig/NotifyExtension.php @@ -22,8 +22,10 @@ final class NotifyExtension extends AbstractExtension /** * @return iterable */ - public function getFunctions(): iterable + public function getFunctions(): array { - yield new TwigFunction('stream_notifications', [NotifyRuntime::class, 'renderStreamNotifications'], ['is_safe' => ['html']]); + return [ + new TwigFunction('stream_notifications', [NotifyRuntime::class, 'renderStreamNotifications'], ['is_safe' => ['html']]), + ]; } } diff --git a/src/Turbo/src/Twig/TwigExtension.php b/src/Turbo/src/Twig/TwigExtension.php index 601e1586524..87dc3fe58fc 100644 --- a/src/Turbo/src/Twig/TwigExtension.php +++ b/src/Turbo/src/Twig/TwigExtension.php @@ -27,9 +27,11 @@ public function __construct( ) { } - public function getFunctions(): iterable + public function getFunctions(): array { - yield new TwigFunction('turbo_stream_listen', $this->turboStreamListen(...), ['needs_environment' => true, 'is_safe' => ['html']]); + return [ + new TwigFunction('turbo_stream_listen', $this->turboStreamListen(...), ['needs_environment' => true, 'is_safe' => ['html']]), + ]; } /**