Skip to content

Commit be52d42

Browse files
committed
Fix Diff::getText() when $end is null
Signed-off-by: Jack Cherng <[email protected]>
1 parent 3a6259a commit be52d42

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Diff.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,12 @@ public function render(AbstractRenderer $renderer): string
226226
*
227227
* @param string[] $lines the array of lines
228228
* @param int $start the starting number
229-
* @param null|int $end the ending number. If not supplied, only the item in $start will be returned.
229+
* @param null|int $end the ending number. If not supplied, only the item in $start will be sliced.
230230
*
231231
* @return string[] array of all of the lines between the specified range
232232
*/
233233
private function getText(array $lines, int $start = 0, ?int $end = null): array
234234
{
235-
return $start === 0 && (!isset($end) || $end === \count($lines))
236-
? $lines
237-
: \array_slice($lines, $start, isset($end) ? $end - $start : 1);
235+
return \array_slice($lines, $start, ($end ?? $start + 1) - $start);
238236
}
239237
}

0 commit comments

Comments
 (0)