Skip to content

Commit

Permalink
Fix Twig extension return types
Browse files Browse the repository at this point in the history
Prepare Twig 4.0 compatibility
  • Loading branch information
smnandre committed Aug 17, 2024
1 parent 2ded754 commit c42b964
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/LazyImage/src/Twig/BlurHashExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
];
}
}
6 changes: 4 additions & 2 deletions src/Map/src/Twig/MapExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']]),
];
}
}
6 changes: 4 additions & 2 deletions src/Notify/src/Twig/NotifyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ final class NotifyExtension extends AbstractExtension
/**
* @return iterable<TwigFunction>
*/
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']]),
];
}
}
6 changes: 4 additions & 2 deletions src/Turbo/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']]),
];
}

/**
Expand Down

0 comments on commit c42b964

Please sign in to comment.