From cb0d0781bcc6b0ae39d73715c659a6d2717d28e1 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Wed, 9 May 2018 08:32:46 +0200 Subject: [PATCH] Renderer/Html/Array: Fix Undefined offset for callback fixSpaces It avoids breaking the callback when no spaces are to be counted. This is a fixup for 2900dd97eb540488c0bc188a0f5b2b6224a41ddd (#42) --- lib/Diff/Renderer/Html/Array.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Diff/Renderer/Html/Array.php b/lib/Diff/Renderer/Html/Array.php index 521601c6..2fe96254 100644 --- a/lib/Diff/Renderer/Html/Array.php +++ b/lib/Diff/Renderer/Html/Array.php @@ -190,9 +190,14 @@ protected function formatLines($lines) */ private function fixSpaces(array $matches) { - $spaces = $matches[1]; - $count = strlen($spaces); - if($count == 0) { + $count = 0; + + if (count($matches) > 1) { + $spaces = $matches[1]; + $count = strlen($spaces); + } + + if ($count == 0) { return ''; }