From 7b829bbde1088a8c37b181f7bfb571f14a14c5ba Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Mon, 4 Sep 2023 12:34:32 +0100 Subject: [PATCH 1/2] Set default range counts --- src/Gitonomy/Git/Parser/DiffParser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Gitonomy/Git/Parser/DiffParser.php b/src/Gitonomy/Git/Parser/DiffParser.php index e14f879..4faf59d 100644 --- a/src/Gitonomy/Git/Parser/DiffParser.php +++ b/src/Gitonomy/Git/Parser/DiffParser.php @@ -102,9 +102,9 @@ protected function doParse() while ($this->expects('@@ ')) { $vars = $this->consumeRegexp('/-(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/'); $rangeOldStart = (int) $vars[1]; - $rangeOldCount = (int) $vars[2]; + $rangeOldCount = $vars[2] ?? 1; $rangeNewStart = (int) $vars[3]; - $rangeNewCount = isset($vars[4]) ? (int) $vars[4] : (int) $vars[2]; // @todo Ici, t'as pris un gros raccourci mon loulou + $rangeNewCount = $vars[4] ?? 1; $this->consume(' @@'); $this->consumeTo("\n"); $this->consumeNewLine(); From b710c65dce4cd24ac234fb719a63e794f5307c91 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Mon, 4 Sep 2023 12:37:27 +0100 Subject: [PATCH 2/2] Force ints --- src/Gitonomy/Git/Parser/DiffParser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Gitonomy/Git/Parser/DiffParser.php b/src/Gitonomy/Git/Parser/DiffParser.php index 4faf59d..28f6c18 100644 --- a/src/Gitonomy/Git/Parser/DiffParser.php +++ b/src/Gitonomy/Git/Parser/DiffParser.php @@ -102,9 +102,9 @@ protected function doParse() while ($this->expects('@@ ')) { $vars = $this->consumeRegexp('/-(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/'); $rangeOldStart = (int) $vars[1]; - $rangeOldCount = $vars[2] ?? 1; + $rangeOldCount = (int) ($vars[2] ?? 1); $rangeNewStart = (int) $vars[3]; - $rangeNewCount = $vars[4] ?? 1; + $rangeNewCount = (int) ($vars[4] ?? 1); $this->consume(' @@'); $this->consumeTo("\n"); $this->consumeNewLine();