update v1.0.4
This commit is contained in:
49
vendor/sebastian/diff/src/Differ.php
vendored
49
vendor/sebastian/diff/src/Differ.php
vendored
@@ -16,13 +16,6 @@ use SebastianBergmann\Diff\LCS\MemoryEfficientImplementation;
|
||||
|
||||
/**
|
||||
* Diff implementation.
|
||||
*
|
||||
* @package Diff
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @author Kore Nordmann <mail@kore-nordmann.de>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://www.github.com/sebastianbergmann/diff
|
||||
*/
|
||||
class Differ
|
||||
{
|
||||
@@ -31,20 +24,27 @@ class Differ
|
||||
*/
|
||||
private $header;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $showNonDiffLines;
|
||||
|
||||
/**
|
||||
* @param string $header
|
||||
*/
|
||||
public function __construct($header = "--- Original\n+++ New\n")
|
||||
public function __construct($header = "--- Original\n+++ New\n", $showNonDiffLines = true)
|
||||
{
|
||||
$this->header = $header;
|
||||
$this->header = $header;
|
||||
$this->showNonDiffLines = $showNonDiffLines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the diff between two arrays or strings as string.
|
||||
*
|
||||
* @param array|string $from
|
||||
* @param array|string $to
|
||||
* @param LongestCommonSubsequence $lcs
|
||||
* @param array|string $from
|
||||
* @param array|string $to
|
||||
* @param LongestCommonSubsequence $lcs
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function diff($from, $to, LongestCommonSubsequence $lcs = null)
|
||||
@@ -97,7 +97,9 @@ class Differ
|
||||
}
|
||||
|
||||
if ($newChunk) {
|
||||
$buffer .= "@@ @@\n";
|
||||
if ($this->showNonDiffLines === true) {
|
||||
$buffer .= "@@ @@\n";
|
||||
}
|
||||
$newChunk = false;
|
||||
}
|
||||
|
||||
@@ -105,7 +107,7 @@ class Differ
|
||||
$buffer .= '+' . $diff[$i][0] . "\n";
|
||||
} elseif ($diff[$i][1] === 2 /* REMOVED */) {
|
||||
$buffer .= '-' . $diff[$i][0] . "\n";
|
||||
} else {
|
||||
} elseif ($this->showNonDiffLines === true) {
|
||||
$buffer .= ' ' . $diff[$i][0] . "\n";
|
||||
}
|
||||
}
|
||||
@@ -124,9 +126,10 @@ class Differ
|
||||
* - 1: ADDED: $token was added to $from
|
||||
* - 0: OLD: $token is not changed in $to
|
||||
*
|
||||
* @param array|string $from
|
||||
* @param array|string $to
|
||||
* @param LongestCommonSubsequence $lcs
|
||||
* @param array|string $from
|
||||
* @param array|string $to
|
||||
* @param LongestCommonSubsequence $lcs
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function diffToArray($from, $to, LongestCommonSubsequence $lcs = null)
|
||||
@@ -221,8 +224,9 @@ class Differ
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $from
|
||||
* @param array $to
|
||||
* @param array $from
|
||||
* @param array $to
|
||||
*
|
||||
* @return LongestCommonSubsequence
|
||||
*/
|
||||
private function selectLcsImplementation(array $from, array $to)
|
||||
@@ -243,9 +247,10 @@ class Differ
|
||||
/**
|
||||
* Calculates the estimated memory footprint for the DP-based method.
|
||||
*
|
||||
* @param array $from
|
||||
* @param array $to
|
||||
* @return integer
|
||||
* @param array $from
|
||||
* @param array $to
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function calculateEstimatedFootprint(array $from, array $to)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user