Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Differ.php

function Differ::getArrayDiffParted

1 call to Differ::getArrayDiffParted()
Differ::diffToArray in vendor/sebastian/diff/src/Differ.php

File

vendor/sebastian/diff/src/Differ.php, line 200

Class

Differ

Namespace

SebastianBergmann\Diff

Code

private static function getArrayDiffParted(array &$from, array &$to) : array {
    $start = [];
    $end = [];
    reset($to);
    foreach ($from as $k => $v) {
        $toK = key($to);
        if ($toK === $k && $v === $to[$k]) {
            $start[$k] = $v;
            unset($from[$k], $to[$k]);
        }
        else {
            break;
        }
    }
    end($from);
    end($to);
    do {
        $fromK = key($from);
        $toK = key($to);
        if (null === $fromK || null === $toK || current($from) !== current($to)) {
            break;
        }
        prev($from);
        prev($to);
        $end = [
            $fromK => $from[$fromK],
        ] + $end;
        unset($from[$fromK], $to[$toK]);
    } while (true);
    return [
        $from,
        $to,
        $start,
        $end,
    ];
}
RSS feed
Powered by Drupal