DiffOpChange example

$this->closing = $closing;
  }

  /** * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no * replacement. * * @see https://www.drupal.org/node/3337942 */
  public function reverse() {
    @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3337942', E_USER_DEPRECATED);
    return new DiffOpChange($this->closing, $this->orig);
  }

}

  public function provideTestDiff(): array {
    return [
      'empty' => [[][][]],
      'add' => [[new DiffOpAdd(['a'])][]['a']],
      'copy' => [[new DiffOpCopy(['a'])]['a']['a']],
      'change' => [[new DiffOpChange(['a']['b'])]['a']['b']],
      'copy-and-change' => [
        [
          new DiffOpCopy(['a']),
          new DiffOpChange(['b']['c']),
        ],
        ['a', 'b'],
        ['a', 'c'],
      ],
      'copy-change-copy' => [
        [
          new DiffOpCopy(['a']),
          

      // Find deletes & adds.       $delete = [];
      while ($xi < $n_from && $this->xchanged[$xi]) {
        $delete[] = $from_lines[$xi++];
      }
      $add = [];
      while ($yi < $n_to && $this->ychanged[$yi]) {
        $add[] = $to_lines[$yi++];
      }
      if ($delete && $add) {
        $edits[] = new DiffOpChange($delete$add);
      }
      elseif ($delete) {
        $edits[] = new DiffOpDelete($delete);
      }
      elseif ($add) {
        $edits[] = new DiffOpAdd($add);
      }
    }
    return $edits;
  }

  

  private function hunkOp(int $mode, array $source, array $target): DiffOp {
    switch ($mode) {
      case Differ::OLD:
        return new DiffOpCopy($source);

      case self::CHANGED:
        return new DiffOpChange($source$target);

      case Differ::ADDED:
        return new DiffOpAdd($source);

      case Differ::REMOVED:
        return new DiffOpDelete($source);

    }
    throw new \InvalidArgumentException("Invalid \$mode {$mode} specified");
  }

}
Home | Imprint | This part of the site doesn't use cookies.