fix:repo cleanup

This commit is contained in:
2025-11-08 20:09:07 +00:00
parent f1da93791d
commit dedcc73567
1204 changed files with 121800 additions and 16971 deletions
+11 -4
View File
@@ -2,6 +2,12 @@
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [7.0.0] - 2025-02-07
### Removed
* This component is no longer supported on PHP 8.3
## [6.0.2] - 2024-07-03
### Changed
@@ -21,7 +27,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* `SebastianBergmann\Diff\Chunk::getStart()`, `SebastianBergmann\Diff\Chunk::getStartRange()`, `SebastianBergmann\Diff\Chunk::getEnd()`, `SebastianBergmann\Diff\Chunk::getEndRange()`, and `SebastianBergmann\Diff\Chunk::getLines()`
* `SebastianBergmann\Diff\Diff::getFrom()`, `SebastianBergmann\Diff\Diff::getTo()`, and `SebastianBergmann\Diff\Diff::getChunks()`
* `SebastianBergmann\Diff\Line::getContent()` and `SebastianBergmann\Diff\Diff::getType()`
* Removed support for PHP 8.1
* This component is no longer supported on PHP 8.1
## [5.1.1] - 2024-03-02
@@ -75,7 +81,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
### Removed
* Removed support for PHP 7.3, PHP 7.4, and PHP 8.0
* This component is no longer supported on PHP 7.3, PHP 7.4, and PHP 8.0
## [4.0.4] - 2020-10-26
@@ -105,7 +111,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
### Removed
* Removed support for PHP 7.1 and PHP 7.2
* This component is no longer supported on PHP 7.1 and PHP 7.2
## [3.0.2] - 2019-02-04
@@ -129,7 +135,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
### Removed
* Removed support for PHP 7.0
* This component is no longer supported on PHP 7.0
### Fixed
@@ -151,6 +157,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* This component is no longer supported on PHP 5.6
[7.0.0]: https://github.com/sebastianbergmann/diff/compare/6.0...7.0.0
[6.0.2]: https://github.com/sebastianbergmann/diff/compare/6.0.1...6.0.2
[6.0.1]: https://github.com/sebastianbergmann/diff/compare/6.0.0...6.0.1
[6.0.0]: https://github.com/sebastianbergmann/diff/compare/5.1...6.0.0
+1 -1
View File
@@ -1,6 +1,6 @@
BSD 3-Clause License
Copyright (c) 2002-2024, Sebastian Bergmann
Copyright (c) 2002-2025, Sebastian Bergmann
All rights reserved.
Redistribution and use in source and binary forms, with or without
+13 -67
View File
@@ -1,4 +1,4 @@
[![Latest Stable Version](https://poser.pugx.org/sebastian/diff/v/stable.png)](https://packagist.org/packages/sebastian/diff)
[![Latest Stable Version](https://poser.pugx.org/sebastian/diff/v)](https://packagist.org/packages/sebastian/diff)
[![CI Status](https://github.com/sebastianbergmann/diff/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/diff/actions)
[![codecov](https://codecov.io/gh/sebastianbergmann/diff/branch/main/graph/badge.svg)](https://codecov.io/gh/sebastianbergmann/diff)
@@ -27,14 +27,17 @@ composer require --dev sebastian/diff
The `Differ` class can be used to generate a textual representation of the difference between two strings:
```php
<?php
<?php declare(strict_types=1);
use SebastianBergmann\Diff\Differ;
use SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder;
$differ = new Differ(new UnifiedDiffOutputBuilder);
$differ = new Differ;
print $differ->diff('foo', 'bar');
```
The code above yields the output below:
```diff
--- Original
+++ New
@@ -43,73 +46,16 @@ The code above yields the output below:
+bar
```
There are three output builders available in this package:
The `UnifiedDiffOutputBuilder` used in the example above generates output in "unified diff"
format and is used by PHPUnit, for example.
#### UnifiedDiffOutputBuilder
The `StrictUnifiedDiffOutputBuilder` generates output in "strict unified diff" format with
hunks, similar to `diff -u` and compatible with `patch` or `git apply`.
This is default builder, which generates the output close to udiff and is used by PHPUnit.
The `DiffOnlyOutputBuilder` generates output that only contains the lines that differ.
```php
<?php
use SebastianBergmann\Diff\Differ;
use SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder;
$builder = new UnifiedDiffOutputBuilder(
"--- Original\n+++ New\n", // custom header
false // do not add line numbers to the diff
);
$differ = new Differ($builder);
print $differ->diff('foo', 'bar');
```
#### StrictUnifiedDiffOutputBuilder
Generates (strict) Unified diff's (unidiffs) with hunks,
similar to `diff -u` and compatible with `patch` and `git apply`.
```php
<?php
use SebastianBergmann\Diff\Differ;
use SebastianBergmann\Diff\Output\StrictUnifiedDiffOutputBuilder;
$builder = new StrictUnifiedDiffOutputBuilder([
'collapseRanges' => true, // ranges of length one are rendered with the trailing `,1`
'commonLineThreshold' => 6, // number of same lines before ending a new hunk and creating a new one (if needed)
'contextLines' => 3, // like `diff: -u, -U NUM, --unified[=NUM]`, for patch/git apply compatibility best to keep at least @ 3
'fromFile' => '',
'fromFileDate' => null,
'toFile' => '',
'toFileDate' => null,
]);
$differ = new Differ($builder);
print $differ->diff('foo', 'bar');
```
#### DiffOnlyOutputBuilder
Output only the lines that differ.
```php
<?php
use SebastianBergmann\Diff\Differ;
use SebastianBergmann\Diff\Output\DiffOnlyOutputBuilder;
$builder = new DiffOnlyOutputBuilder(
"--- Original\n+++ New\n"
);
$differ = new Differ($builder);
print $differ->diff('foo', 'bar');
```
#### DiffOutputBuilderInterface
You can pass any output builder to the `Differ` class as longs as it implements the `DiffOutputBuilderInterface`.
If none of these three output builders match your use case then you can implement
`DiffOutputBuilderInterface` to generate custom output.
#### Parsing diff
+5 -5
View File
@@ -21,17 +21,17 @@
"prefer-stable": true,
"config": {
"platform": {
"php": "8.2.0"
"php": "8.3.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"require": {
"php": ">=8.2"
"php": ">=8.3"
},
"require-dev": {
"phpunit/phpunit": "^11.0",
"symfony/process": "^4.2 || ^5"
"phpunit/phpunit": "^12.0",
"symfony/process": "^7.2"
},
"autoload": {
"classmap": [
@@ -45,7 +45,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "6.0-dev"
"dev-main": "7.0-dev"
}
}
}
-6
View File
@@ -73,12 +73,6 @@ 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;
}
+8 -8
View File
@@ -30,11 +30,11 @@ use SebastianBergmann\Diff\Output\DiffOutputBuilderInterface;
final class Differ
{
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;
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;
private DiffOutputBuilderInterface $outputBuilder;
public function __construct(DiffOutputBuilderInterface $outputBuilder)
@@ -84,11 +84,11 @@ final class Differ
reset($to);
foreach ($common as $token) {
while (($fromToken = reset($from)) !== $token) {
while ((/* from-token */ reset($from)) !== $token) {
$diff[] = [array_shift($from), self::REMOVED];
}
while (($toToken = reset($to)) !== $token) {
while ((/* to-token */ 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): float|int
private function calculateEstimatedFootprint(array $from, array $to): int
{
$itemSize = PHP_INT_SIZE === 4 ? 76 : 144;
+3 -3
View File
@@ -11,9 +11,9 @@ namespace SebastianBergmann\Diff;
final class Line
{
public const ADDED = 1;
public const REMOVED = 2;
public const UNCHANGED = 3;
public const int ADDED = 1;
public const int REMOVED = 2;
public const int UNCHANGED = 3;
private int $type;
private string $content;
@@ -15,7 +15,6 @@ use function array_reverse;
use function array_slice;
use function count;
use function in_array;
use function max;
final class MemoryEfficientLongestCommonSubsequenceCalculator implements LongestCommonSubsequenceCalculator
{
@@ -16,6 +16,8 @@ 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,9 +9,11 @@
*/
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;
@@ -34,6 +36,8 @@ final class DiffOnlyOutputBuilder implements DiffOutputBuilderInterface
{
$buffer = fopen('php://memory', 'r+b');
assert(is_resource($buffer));
if ('' !== $this->header) {
fwrite($buffer, $this->header);
@@ -11,12 +11,14 @@ 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;
@@ -99,6 +101,9 @@ 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,10 +10,12 @@
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;
@@ -46,6 +48,8 @@ final class UnifiedDiffOutputBuilder extends AbstractChunkOutputBuilder
{
$buffer = fopen('php://memory', 'r+b');
assert(is_resource($buffer));
if ('' !== $this->header) {
fwrite($buffer, $this->header);
+4
View File
@@ -9,6 +9,7 @@
*/
namespace SebastianBergmann\Diff;
use const PREG_UNMATCHED_AS_NULL;
use function array_pop;
use function assert;
use function count;
@@ -71,6 +72,9 @@ final class Parser
return $diffs;
}
/**
* @param string[] $lines
*/
private function parseFileDiff(Diff $diff, array $lines): void
{
$chunks = [];
@@ -11,7 +11,6 @@ namespace SebastianBergmann\Diff;
use function array_reverse;
use function count;
use function max;
use SplFixedArray;
final class TimeEfficientLongestCommonSubsequenceCalculator implements LongestCommonSubsequenceCalculator