From b7801f37c4b14476fe32be3cb5b5d694de04499a Mon Sep 17 00:00:00 2001 From: hillsinfoodle <81539583+hillsinfoodle@users.noreply.github.com> Date: Thu, 23 Mar 2023 11:20:18 +1300 Subject: [PATCH] Update AbstractGenerator.php stop null warnings/errors when null options are set, noticed these in php8.1 --- src/Knp/Snappy/AbstractGenerator.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Knp/Snappy/AbstractGenerator.php b/src/Knp/Snappy/AbstractGenerator.php index 643376f2..52546a13 100644 --- a/src/Knp/Snappy/AbstractGenerator.php +++ b/src/Knp/Snappy/AbstractGenerator.php @@ -536,21 +536,21 @@ protected function buildCommand($binary, $input, $output, array $options = []) } elseif (\is_array($option)) { if ($this->isAssociativeArray($option)) { foreach ($option as $k => $v) { - $command .= ' --' . $key . ' ' . \escapeshellarg($k) . ' ' . \escapeshellarg($v); + $command .= ' --' . $key . ' ' . \escapeshellarg($k) . ' ' . \escapeshellarg($v ?? ''); } } else { foreach ($option as $v) { - $command .= ' --' . $key . ' ' . \escapeshellarg($v); + $command .= ' --' . $key . ' ' . \escapeshellarg($v ?? ''); } } } else { // Dont't add '--' if option is "cover" or "toc". if (\in_array($key, ['toc', 'cover'])) { - $command .= ' ' . $key . ' ' . \escapeshellarg($option); + $command .= ' ' . $key . ' ' . \escapeshellarg($option ?? ''); } elseif (\in_array($key, ['image-dpi', 'image-quality'])) { $command .= ' --' . $key . ' ' . (int) $option; } else { - $command .= ' --' . $key . ' ' . \escapeshellarg($option); + $command .= ' --' . $key . ' ' . \escapeshellarg($option ?? ''); } } }