function Diff::check

Same name in other branches
  1. 9 core/lib/Drupal/Component/Diff/Diff.php \Drupal\Component\Diff\Diff::check()
  2. 8.9.x core/lib/Drupal/Component/Diff/Diff.php \Drupal\Component\Diff\Diff::check()

Check a Diff for validity.

This is here only for debugging purposes.

Deprecated

in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement.

See also

https://www.drupal.org/node/3337942

File

core/lib/Drupal/Component/Diff/Diff.php, line 168

Class

Diff
Class representing a 'diff' between two sequences of strings.

Namespace

Drupal\Component\Diff

Code

public function check($from_lines, $to_lines) {
    @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);
    if (serialize($from_lines) != serialize($this->orig())) {
        trigger_error("Reconstructed original doesn't match", E_USER_ERROR);
    }
    if (serialize($to_lines) != serialize($this->closing())) {
        trigger_error("Reconstructed closing doesn't match", E_USER_ERROR);
    }
    $rev = $this->reverse();
    if (serialize($to_lines) != serialize($rev->orig())) {
        trigger_error("Reversed original doesn't match", E_USER_ERROR);
    }
    if (serialize($from_lines) != serialize($rev->closing())) {
        trigger_error("Reversed closing doesn't match", E_USER_ERROR);
    }
    $prevtype = 'none';
    foreach ($this->edits as $edit) {
        if ($prevtype == $edit->type) {
            trigger_error("Edit sequence is non-optimal", E_USER_ERROR);
        }
        $prevtype = $edit->type;
    }
    $lcs = $this->lcs();
    trigger_error('Diff okay: LCS = ' . $lcs, E_USER_NOTICE);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.