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

Breadcrumb

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

class Diff

Same name in this branch
  1. 11.1.x vendor/sebastian/diff/src/Diff.php \SebastianBergmann\Diff\Diff
  2. 11.1.x vendor/squizlabs/php_codesniffer/src/Reports/Diff.php \PHP_CodeSniffer\Reports\Diff

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

Component code originally taken from https://www.drupal.org/project/diff which was itself based on the PHP diff engine for phpwiki. The original code in phpwiki was copyright (C) 2000, 2001 Geoffrey T. Dairiki <dairiki@dairiki.org> and licensed under GPL.

Hierarchy

  • class \Drupal\Component\Diff\Diff

Expanded class hierarchy of Diff

1 file declares its use of Diff
ConfigManager.php in core/lib/Drupal/Core/Config/ConfigManager.php
10 string references to 'Diff'
CodeBlock::defaultConfiguration in core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/CodeBlock.php
CodeBlock::defaultConfiguration in core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/CodeBlock.php
editor.editor.full_html.yml in core/profiles/standard/config/install/editor.editor.full_html.yml
core/profiles/standard/config/install/editor.editor.full_html.yml
editor.editor.full_html.yml in core/profiles/standard/config/install/editor.editor.full_html.yml
core/profiles/standard/config/install/editor.editor.full_html.yml
editor.editor.full_html.yml in core/recipes/full_html_format_editor/config/editor.editor.full_html.yml
core/recipes/full_html_format_editor/config/editor.editor.full_html.yml

... See full list

File

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

Namespace

Drupal\Component\Diff
View source
class Diff {
    
    /**
     * The list of differences as an array of diff operations.
     *
     * @var \Drupal\Component\Diff\Engine\DiffOp[]
     */
    protected $edits;
    
    /**
     * Constructor.
     * Computes diff between sequences of strings.
     *
     * @param array $from_lines
     *   An array of strings.
     *   (Typically these are lines from a file.)
     * @param array $to_lines
     *   An array of strings.
     */
    public function __construct($from_lines, $to_lines) {
        $diffOpBuilder = new DiffOpOutputBuilder();
        $differ = new Differ($diffOpBuilder);
        $this->edits = $diffOpBuilder->toOpsArray($differ->diffToArray($from_lines, $to_lines));
    }
    
    /**
     * Gets the list of differences as an array of diff operations.
     *
     * @return \Drupal\Component\Diff\Engine\DiffOp[]
     *   The list of differences as an array of diff operations.
     */
    public function getEdits() {
        return $this->edits;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
Diff::$edits protected property The list of differences as an array of diff operations.
Diff::getEdits public function Gets the list of differences as an array of diff operations.
Diff::__construct public function Constructor.
Computes diff between sequences of strings.
1
RSS feed
Powered by Drupal