Skip to content

Commit ed0b773

Browse files
committed
[skip ci] Avoid infinite loop in differ
TBH I don't understand why this can happen here but not in sebastian/diff. I'll have to take a closer look.
1 parent fced34e commit ed0b773

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

run-tests.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3982,11 +3982,11 @@ public function diffToArray(array $from, array $to): array
39823982
reset($to);
39833983

39843984
foreach ($common as $token) {
3985-
while (!($this->isEqual)(reset($from), $token)) {
3985+
while (!empty($from) && !($this->isEqual)(reset($from), $token)) {
39863986
$diff[] = [array_shift($from), self::REMOVED, $fromLine++];
39873987
}
39883988

3989-
while (!($this->isEqual)($token, reset($to))) {
3989+
while (!empty($to) && !($this->isEqual)($token, reset($to))) {
39903990
$diff[] = [array_shift($to), self::ADDED, $toLine++];
39913991
}
39923992

0 commit comments

Comments
 (0)