Skip to content

Commit b680f9e

Browse files
committed
Fix: This is impossible due that the start parameter has to be "$start < 0 || $end < 0 || $end < $start"
1 parent 1cf2193 commit b680f9e

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

lib/jblond/Diff.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,6 @@ public function getArrayRange(array $array, int $start = 0, ?int $end = null): a
217217
return $array;
218218
}
219219

220-
if ($end === null) {
221-
//Return single element.
222-
return array_slice($array, $start, 1);
223-
}
224-
225220
//Return range of elements.
226221
$length = $end - $start;
227222

tests/DiffTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,25 @@ public function testGetStatistics()
142142
public function testGetArrayRange()
143143
{
144144
$this->assertEquals(
145-
[5,6],
145+
[5, 6],
146146
$this->diff->getArrayRange([2,5,6],1, 3)
147147
);
148148

149+
$this->assertEquals(
150+
[2, 5, 6],
151+
$this->diff->getArrayRange([2,5,6],0, 3)
152+
);
153+
154+
$this->assertEquals(
155+
[2, 5, 6],
156+
$this->diff->getArrayRange([2,5,6],0, null)
157+
);
158+
159+
$this->assertEquals(
160+
[2, 5, 6],
161+
$this->diff->getArrayRange([2,5,6],1, null)
162+
);
163+
149164
$this->expectException(OutOfRangeException::class);
150165
$this->diff->getArrayRange([1,5],5);
151166
}

0 commit comments

Comments
 (0)