From 4a0897a2de43beb0b01a9af2fdb48dea5d3611b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 4 Feb 2025 15:04:49 +0100 Subject: [PATCH] fix: avoid null-pointer exception --- src/Twig/AppRuntime.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Twig/AppRuntime.php b/src/Twig/AppRuntime.php index d3afdfd..5b82edc 100644 --- a/src/Twig/AppRuntime.php +++ b/src/Twig/AppRuntime.php @@ -156,8 +156,12 @@ class AppRuntime implements RuntimeExtensionInterface return sprintf('%s', $class, $label); } - public function nl2List(string $content, string $class = 'list-disc pl-4'): string + public function nl2List(?string $content, string $class = 'list-disc pl-4'): string { + if (null === $content) { + return ''; + } + $items = explode(PHP_EOL, $content); $list = '