From 7ecf638b13ed35cd87146c9b8333d7c879d4044d Mon Sep 17 00:00:00 2001 From: zymurgic Date: Sat, 10 Jul 2021 08:06:38 +0100 Subject: [PATCH] fix warnings for undefined tags for $lineStyle (#378) Under PHP8, this generated warnings. If a tag is not set, it would throw a warning. Because the downstream usage of the $lineStyle can handle undefined entries, it's safe to leave them unset here. Co-authored-by: Nicola Asuni --- tcpdf.php | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/tcpdf.php b/tcpdf.php index 24106ea..a929e08 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -18917,13 +18917,30 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: $prevlinewidth = $this->GetLineWidth(); $this->SetLineWidth($hrHeight); - $lineStyle = array( - 'color' => $tag['fgcolor'], - 'cap' => $tag['style']['cap'], - 'join' => $tag['style']['join'], - 'dash' => $tag['style']['dash'], - 'phase' => $tag['style']['phase'], - ); + $lineStyle = array(); + if (isset($tag['fgcolor'])) { + $lineStyle['color'] = $tag['fgcolor']; + } + + if (isset($tag['fgcolor'])) { + $lineStyle['color'] = $tag['fgcolor']; + } + + if (isset($tag['style']['cap'])) { + $lineStyle['cap'] = $tag['style']['cap']; + } + + if (isset($tag['style']['join'])) { + $lineStyle['join'] = $tag['style']['join']; + } + + if (isset($tag['style']['dash'])) { + $lineStyle['dash'] = $tag['style']['dash']; + } + + if (isset($tag['style']['phase'])) { + $lineStyle['phase'] = $tag['style']['phase']; + } $lineStyle = array_filter($lineStyle);