class Diff

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Component/Diff/Diff.php \Drupal\Component\Diff\Diff
  2. 8.9.x core/lib/Drupal/Component/Diff/Diff.php \Drupal\Component\Diff\Diff
  3. 10 core/lib/Drupal/Component/Diff/Diff.php \Drupal\Component\Diff\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 <[email protected]> and licensed under GPL.

Hierarchy

  • class \Drupal\Component\Diff\Diff

Expanded class hierarchy of Diff

3 files declare their use of Diff
AssertConfigTrait.php in core/tests/Drupal/KernelTests/AssertConfigTrait.php
ConfigManager.php in core/lib/Drupal/Core/Config/ConfigManager.php
DiffFormatterTest.php in core/tests/Drupal/Tests/Component/Diff/DiffFormatterTest.php
13 string references to 'Diff'
CKEditor5UpdateCodeBlockConfigurationTest::testUpdateCodeBlockConfigurationPostUpdate in core/modules/ckeditor5/tests/src/Functional/Update/CKEditor5UpdateCodeBlockConfigurationTest.php
Ensure default configuration for the CKEditor 5 codeBlock plugin is added.
CKEditor5UpdateCodeBlockConfigurationTest::testUpdateCodeBlockConfigurationPostUpdate in core/modules/ckeditor5/tests/src/Functional/Update/CKEditor5UpdateCodeBlockConfigurationTest.php
Ensure default configuration for the CKEditor 5 codeBlock plugin is added.
CodeBlock::defaultConfiguration in core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/CodeBlock.php
CodeBlock::defaultConfiguration in core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/CodeBlock.php
ConfigurablePluginTest::testDefaults in core/modules/ckeditor5/tests/src/Kernel/ConfigurablePluginTest.php
Tests default settings for configurable CKEditor 5 plugins.

... 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

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