20250204
This commit is contained in:
6
vendor/sebastian/diff/src/Chunk.php
vendored
6
vendor/sebastian/diff/src/Chunk.php
vendored
@@ -73,6 +73,12 @@ final class Chunk implements IteratorAggregate
|
||||
*/
|
||||
public function setLines(array $lines): void
|
||||
{
|
||||
foreach ($lines as $line) {
|
||||
if (!$line instanceof Line) {
|
||||
throw new InvalidArgumentException;
|
||||
}
|
||||
}
|
||||
|
||||
$this->lines = $lines;
|
||||
}
|
||||
|
||||
|
16
vendor/sebastian/diff/src/Differ.php
vendored
16
vendor/sebastian/diff/src/Differ.php
vendored
@@ -30,11 +30,11 @@ use SebastianBergmann\Diff\Output\DiffOutputBuilderInterface;
|
||||
|
||||
final class Differ
|
||||
{
|
||||
public const int OLD = 0;
|
||||
public const int ADDED = 1;
|
||||
public const int REMOVED = 2;
|
||||
public const int DIFF_LINE_END_WARNING = 3;
|
||||
public const int NO_LINE_END_EOF_WARNING = 4;
|
||||
public const OLD = 0;
|
||||
public const ADDED = 1;
|
||||
public const REMOVED = 2;
|
||||
public const DIFF_LINE_END_WARNING = 3;
|
||||
public const NO_LINE_END_EOF_WARNING = 4;
|
||||
private DiffOutputBuilderInterface $outputBuilder;
|
||||
|
||||
public function __construct(DiffOutputBuilderInterface $outputBuilder)
|
||||
@@ -84,11 +84,11 @@ final class Differ
|
||||
reset($to);
|
||||
|
||||
foreach ($common as $token) {
|
||||
while ((/* from-token */ reset($from)) !== $token) {
|
||||
while (($fromToken = reset($from)) !== $token) {
|
||||
$diff[] = [array_shift($from), self::REMOVED];
|
||||
}
|
||||
|
||||
while ((/* to-token */ reset($to)) !== $token) {
|
||||
while (($toToken = reset($to)) !== $token) {
|
||||
$diff[] = [array_shift($to), self::ADDED];
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ final class Differ
|
||||
return new TimeEfficientLongestCommonSubsequenceCalculator;
|
||||
}
|
||||
|
||||
private function calculateEstimatedFootprint(array $from, array $to): int
|
||||
private function calculateEstimatedFootprint(array $from, array $to): float|int
|
||||
{
|
||||
$itemSize = PHP_INT_SIZE === 4 ? 76 : 144;
|
||||
|
||||
|
6
vendor/sebastian/diff/src/Line.php
vendored
6
vendor/sebastian/diff/src/Line.php
vendored
@@ -11,9 +11,9 @@ namespace SebastianBergmann\Diff;
|
||||
|
||||
final class Line
|
||||
{
|
||||
public const int ADDED = 1;
|
||||
public const int REMOVED = 2;
|
||||
public const int UNCHANGED = 3;
|
||||
public const ADDED = 1;
|
||||
public const REMOVED = 2;
|
||||
public const UNCHANGED = 3;
|
||||
private int $type;
|
||||
private string $content;
|
||||
|
||||
|
@@ -15,6 +15,7 @@ use function array_reverse;
|
||||
use function array_slice;
|
||||
use function count;
|
||||
use function in_array;
|
||||
use function max;
|
||||
|
||||
final class MemoryEfficientLongestCommonSubsequenceCalculator implements LongestCommonSubsequenceCalculator
|
||||
{
|
||||
|
@@ -16,8 +16,6 @@ abstract class AbstractChunkOutputBuilder implements DiffOutputBuilderInterface
|
||||
/**
|
||||
* Takes input of the diff array and returns the common parts.
|
||||
* Iterates through diff line by line.
|
||||
*
|
||||
* @return array<int, positive-int>
|
||||
*/
|
||||
protected function getCommonChunks(array $diff, int $lineThreshold = 5): array
|
||||
{
|
||||
|
@@ -9,11 +9,9 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Diff\Output;
|
||||
|
||||
use function assert;
|
||||
use function fclose;
|
||||
use function fopen;
|
||||
use function fwrite;
|
||||
use function is_resource;
|
||||
use function str_ends_with;
|
||||
use function stream_get_contents;
|
||||
use function substr;
|
||||
@@ -36,8 +34,6 @@ final class DiffOnlyOutputBuilder implements DiffOutputBuilderInterface
|
||||
{
|
||||
$buffer = fopen('php://memory', 'r+b');
|
||||
|
||||
assert(is_resource($buffer));
|
||||
|
||||
if ('' !== $this->header) {
|
||||
fwrite($buffer, $this->header);
|
||||
|
||||
|
@@ -11,14 +11,12 @@ namespace SebastianBergmann\Diff\Output;
|
||||
|
||||
use function array_merge;
|
||||
use function array_splice;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function fclose;
|
||||
use function fopen;
|
||||
use function fwrite;
|
||||
use function is_bool;
|
||||
use function is_int;
|
||||
use function is_resource;
|
||||
use function is_string;
|
||||
use function max;
|
||||
use function min;
|
||||
@@ -101,9 +99,6 @@ final class StrictUnifiedDiffOutputBuilder implements DiffOutputBuilderInterface
|
||||
$this->changed = false;
|
||||
|
||||
$buffer = fopen('php://memory', 'r+b');
|
||||
|
||||
assert(is_resource($buffer));
|
||||
|
||||
fwrite($buffer, $this->header);
|
||||
|
||||
$this->writeDiffHunks($buffer, $diff);
|
||||
|
@@ -10,12 +10,10 @@
|
||||
namespace SebastianBergmann\Diff\Output;
|
||||
|
||||
use function array_splice;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function fclose;
|
||||
use function fopen;
|
||||
use function fwrite;
|
||||
use function is_resource;
|
||||
use function max;
|
||||
use function min;
|
||||
use function str_ends_with;
|
||||
@@ -48,8 +46,6 @@ final class UnifiedDiffOutputBuilder extends AbstractChunkOutputBuilder
|
||||
{
|
||||
$buffer = fopen('php://memory', 'r+b');
|
||||
|
||||
assert(is_resource($buffer));
|
||||
|
||||
if ('' !== $this->header) {
|
||||
fwrite($buffer, $this->header);
|
||||
|
||||
|
4
vendor/sebastian/diff/src/Parser.php
vendored
4
vendor/sebastian/diff/src/Parser.php
vendored
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Diff;
|
||||
|
||||
use const PREG_UNMATCHED_AS_NULL;
|
||||
use function array_pop;
|
||||
use function assert;
|
||||
use function count;
|
||||
@@ -72,9 +71,6 @@ final class Parser
|
||||
return $diffs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $lines
|
||||
*/
|
||||
private function parseFileDiff(Diff $diff, array $lines): void
|
||||
{
|
||||
$chunks = [];
|
||||
|
@@ -11,6 +11,7 @@ namespace SebastianBergmann\Diff;
|
||||
|
||||
use function array_reverse;
|
||||
use function count;
|
||||
use function max;
|
||||
use SplFixedArray;
|
||||
|
||||
final class TimeEfficientLongestCommonSubsequenceCalculator implements LongestCommonSubsequenceCalculator
|
||||
|
Reference in New Issue
Block a user