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
+42
View File
@@ -2,6 +2,42 @@
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [7.1.3] - 2025-08-20
### Changed
* [#130](https://github.com/sebastianbergmann/comparator/pull/130): Provide a diff when `ClosureComparator` fails
## [7.1.2] - 2025-08-10
### Fixed
* `SebastianBergmann\Comparator\Comparator` should not have been marked as private implementation detail of this library
## [7.1.1] - 2025-08-10
### Changed
* Do not use `SplObjectStorage` methods that will be deprecated in PHP 8.5
## [7.1.0] - 2025-06-17
### Added
* [#127](https://github.com/sebastianbergmann/comparator/issues/127): Support for comparing `Closure` objects
## [7.0.1] - 2025-03-07
### Fixed
* [#122](https://github.com/sebastianbergmann/comparator/issues/122): `INF` is considered equal to `-INF`
## [7.0.0] - 2025-02-07
### Removed
* Removed support for PHP 8.2
## [6.3.2] - 2025-08-10
### Changed
@@ -216,6 +252,12 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* Added `SebastianBergmann\Comparator\Factory::reset()` to unregister all non-default comparators
* Added support for `phpunit/phpunit-mock-objects` version `^5.0`
[7.1.3]: https://github.com/sebastianbergmann/comparator/compare/7.1.2...7.1.3
[7.1.2]: https://github.com/sebastianbergmann/comparator/compare/7.1.1...7.1.2
[7.1.1]: https://github.com/sebastianbergmann/comparator/compare/7.1.0...7.1.1
[7.1.0]: https://github.com/sebastianbergmann/comparator/compare/7.0.1...7.1.0
[7.0.1]: https://github.com/sebastianbergmann/comparator/compare/7.0.0...7.0.1
[7.0.0]: https://github.com/sebastianbergmann/comparator/compare/6.3...7.0.0
[6.3.2]: https://github.com/sebastianbergmann/comparator/compare/6.3.1...6.3.2
[6.3.1]: https://github.com/sebastianbergmann/comparator/compare/6.3.0...6.3.1
[6.3.0]: https://github.com/sebastianbergmann/comparator/compare/6.2.1...6.3.0
+6 -6
View File
@@ -28,9 +28,9 @@
},
"prefer-stable": true,
"require": {
"php": ">=8.2",
"sebastian/diff": "^6.0",
"sebastian/exporter": "^6.0",
"php": ">=8.3",
"sebastian/diff": "^7.0",
"sebastian/exporter": "^7.0",
"ext-dom": "*",
"ext-mbstring": "*"
},
@@ -38,11 +38,11 @@
"ext-bcmath": "For comparing BcMath\\Number objects"
},
"require-dev": {
"phpunit/phpunit": "^11.4"
"phpunit/phpunit": "^12.2"
},
"config": {
"platform": {
"php": "8.2.0"
"php": "8.3.0"
},
"optimize-autoloader": true,
"sort-packages": true
@@ -59,7 +59,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "6.3-dev"
"dev-main": "7.1-dev"
}
}
}
+9 -5
View File
@@ -19,9 +19,9 @@ use function trim;
use SebastianBergmann\Exporter\Exporter;
/**
* Arrays are equal if they contain the same key-value pairs.
* The order of the keys does not matter.
* The types of key-value pairs do not matter.
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
class ArrayComparator extends Comparator
{
@@ -31,6 +31,10 @@ class ArrayComparator extends Comparator
}
/**
* Arrays are equal if they contain the same key-value pairs.
* The order of the keys does not matter.
* The types of key-value pairs do not matter.
*
* @param array<mixed> $processed
*
* @throws ComparisonFailure
@@ -87,13 +91,13 @@ class ArrayComparator extends Comparator
$expectedAsString .= sprintf(
" %s => %s\n",
$exporter->export($key),
$e->getExpectedAsString() ? $this->indent($e->getExpectedAsString()) : $exporter->shortenedExport($e->getExpected()),
$e->getExpectedAsString() !== '' ? $this->indent($e->getExpectedAsString()) : $exporter->shortenedExport($e->getExpected()),
);
$actualAsString .= sprintf(
" %s => %s\n",
$exporter->export($key),
$e->getActualAsString() ? $this->indent($e->getActualAsString()) : $exporter->shortenedExport($e->getActual()),
$e->getActualAsString() !== '' ? $this->indent($e->getActualAsString()) : $exporter->shortenedExport($e->getActual()),
);
$equal = false;
+3
View File
@@ -9,6 +9,9 @@
*/
namespace SebastianBergmann\Comparator;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*/
abstract class Comparator
{
private Factory $factory;
+4 -1
View File
@@ -13,6 +13,9 @@ use RuntimeException;
use SebastianBergmann\Diff\Differ;
use SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*/
final class ComparisonFailure extends RuntimeException
{
private mixed $expected;
@@ -52,7 +55,7 @@ final class ComparisonFailure extends RuntimeException
public function getDiff(): string
{
if (!$this->actualAsString && !$this->expectedAsString) {
if ($this->actualAsString === '' && $this->expectedAsString === '') {
return '';
}
+21 -28
View File
@@ -16,6 +16,11 @@ use DOMDocument;
use DOMNode;
use ValueError;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
final class DOMNodeComparator extends ObjectComparator
{
public function accepts(mixed $expected, mixed $actual): bool
@@ -33,8 +38,8 @@ final class DOMNodeComparator extends ObjectComparator
assert($expected instanceof DOMNode);
assert($actual instanceof DOMNode);
$expectedAsString = $this->nodeToText($expected, true, $ignoreCase);
$actualAsString = $this->nodeToText($actual, true, $ignoreCase);
$expectedAsString = $this->nodeToText($expected, $ignoreCase);
$actualAsString = $this->nodeToText($actual, $ignoreCase);
if ($expectedAsString !== $actualAsString) {
$type = $expected instanceof DOMDocument ? 'documents' : 'nodes';
@@ -50,42 +55,30 @@ final class DOMNodeComparator extends ObjectComparator
}
/**
* Returns the normalized, whitespace-cleaned, and indented textual
* representation of a DOMNode.
* Canonicalizes nodes, removes empty text nodes and merges adjacent text nodes,
* and optionally ignores case.
*
* @see https://github.com/sebastianbergmann/phpunit/pull/1236#issuecomment-41765023
*/
private function nodeToText(DOMNode $node, bool $canonicalize, bool $ignoreCase): string
private function nodeToText(DOMNode $node, bool $ignoreCase): string
{
if ($canonicalize) {
$document = new DOMDocument;
$document = new DOMDocument;
try {
$c14n = $node->C14N();
try {
$c14n = $node->C14N();
assert(!empty($c14n));
assert($c14n !== false && $c14n !== '');
@$document->loadXML($c14n);
} catch (ValueError) {
}
$node = $document;
@$document->loadXML($c14n);
// @codeCoverageIgnoreStart
} catch (ValueError) {
// @codeCoverageIgnoreEnd
}
if ($node instanceof DOMDocument) {
$document = $node;
} else {
$document = $node->ownerDocument;
}
assert($document instanceof DOMDocument);
$document->formatOutput = true;
$document->normalizeDocument();
if ($node instanceof DOMDocument) {
$text = $node->saveXML();
} else {
$text = $document->saveXML($node);
}
$text = $document->saveXML();
assert($text !== false);
@@ -18,6 +18,11 @@ use DateTime;
use DateTimeImmutable;
use DateTimeZone;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
final class DateTimeComparator extends ObjectComparator
{
public function accepts(mixed $expected, mixed $actual): bool
@@ -13,6 +13,11 @@ use function assert;
use function sprintf;
use UnitEnum;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
final class EnumerationComparator extends Comparator
{
public function accepts(mixed $expected, mixed $actual): bool
@@ -13,7 +13,9 @@ use function assert;
use Exception;
/**
* Compares Exception instances for equality.
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
final class ExceptionComparator extends ObjectComparator
{
+6
View File
@@ -14,6 +14,9 @@ use function array_unshift;
use function extension_loaded;
use function version_compare;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*/
final class Factory
{
private static ?Factory $instance = null;
@@ -56,7 +59,9 @@ final class Factory
}
}
// @codeCoverageIgnoreStart
throw new RuntimeException('No suitable Comparator implementation found');
// @codeCoverageIgnoreEnd
}
/**
@@ -95,6 +100,7 @@ final class Factory
private function registerDefaultComparators(): void
{
$this->registerDefaultComparator(new ClosureComparator);
$this->registerDefaultComparator(new MockObjectComparator);
$this->registerDefaultComparator(new DateTimeComparator);
$this->registerDefaultComparator(new DOMNodeComparator);
@@ -15,7 +15,9 @@ use function str_starts_with;
use PHPUnit\Framework\MockObject\Stub;
/**
* Compares PHPUnit\Framework\MockObject\MockObject instances for equality.
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
final class MockObjectComparator extends ObjectComparator
{
@@ -17,6 +17,11 @@ use function max;
use function number_format;
use BcMath\Number;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
final class NumberComparator extends ObjectComparator
{
public function accepts(mixed $expected, mixed $actual): bool
@@ -19,6 +19,11 @@ use function is_string;
use function sprintf;
use SebastianBergmann\Exporter\Exporter;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
final class NumericComparator extends ScalarComparator
{
public function accepts(mixed $expected, mixed $actual): bool
@@ -16,6 +16,11 @@ use function sprintf;
use function substr_replace;
use SebastianBergmann\Exporter\Exporter;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
class ObjectComparator extends ArrayComparator
{
public function accepts(mixed $expected, mixed $actual): bool
@@ -13,6 +13,11 @@ use function assert;
use function is_resource;
use SebastianBergmann\Exporter\Exporter;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
final class ResourceComparator extends Comparator
{
public function accepts(mixed $expected, mixed $actual): bool
@@ -30,6 +35,7 @@ final class ResourceComparator extends Comparator
$exporter = new Exporter;
/** @phpstan-ignore notEqual.notAllowed */
if ($actual != $expected) {
throw new ComparisonFailure(
$expected,
+12 -6
View File
@@ -9,6 +9,7 @@
*/
namespace SebastianBergmann\Comparator;
use function assert;
use function is_bool;
use function is_object;
use function is_scalar;
@@ -21,12 +22,14 @@ use function substr;
use SebastianBergmann\Exporter\Exporter;
/**
* Compares scalar or NULL values for equality.
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
class ScalarComparator extends Comparator
{
private const OVERLONG_THRESHOLD = 40;
private const KEEP_CONTEXT_CHARS = 25;
private const int OVERLONG_THRESHOLD = 40;
private const int KEEP_CONTEXT_CHARS = 25;
public function accepts(mixed $expected, mixed $actual): bool
{
@@ -74,6 +77,7 @@ class ScalarComparator extends Comparator
);
}
/** @phpstan-ignore notEqual.notAllowed */
if ($expectedToCompare != $actualToCompare) {
throw new ComparisonFailure(
$expected,
@@ -108,11 +112,13 @@ class ScalarComparator extends Comparator
private static function findCommonPrefix(string $string1, string $string2): string
{
for ($i = 0; $i < strlen($string1); $i++) {
if (!isset($string2[$i]) || $string1[$i] != $string2[$i]) {
if (!isset($string2[$i]) || $string1[$i] !== $string2[$i]) {
break;
}
}
assert(isset($i));
return substr($string1, 0, $i);
}
@@ -140,14 +146,14 @@ class ScalarComparator extends Comparator
$lastCharIndex1 = strlen($string1) - 1;
$lastCharIndex2 = strlen($string2) - 1;
if ($string1[$lastCharIndex1] != $string2[$lastCharIndex2]) {
if ($string1[$lastCharIndex1] !== $string2[$lastCharIndex2]) {
return '';
}
while (
$lastCharIndex1 > 0 &&
$lastCharIndex2 > 0 &&
$string1[$lastCharIndex1] == $string2[$lastCharIndex2]
$string1[$lastCharIndex1] === $string2[$lastCharIndex2]
) {
$lastCharIndex1--;
$lastCharIndex2--;
@@ -13,6 +13,11 @@ use function assert;
use SebastianBergmann\Exporter\Exporter;
use SplObjectStorage;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
final class SplObjectStorageComparator extends Comparator
{
public function accepts(mixed $expected, mixed $actual): bool
+6 -1
View File
@@ -13,6 +13,11 @@ use function gettype;
use function sprintf;
use SebastianBergmann\Exporter\Exporter;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*
* @internal This class is not covered by the backward compatibility promise for sebastian/comparator
*/
final class TypeComparator extends Comparator
{
public function accepts(mixed $expected, mixed $actual): bool
@@ -25,7 +30,7 @@ final class TypeComparator extends Comparator
*/
public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, bool $canonicalize = false, bool $ignoreCase = false): void
{
if (gettype($expected) != gettype($actual)) {
if (gettype($expected) !== gettype($actual)) {
throw new ComparisonFailure(
$expected,
$actual,
@@ -11,6 +11,9 @@ namespace SebastianBergmann\Comparator;
use Throwable;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*/
interface Exception extends Throwable
{
}
@@ -9,6 +9,9 @@
*/
namespace SebastianBergmann\Comparator;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for sebastian/comparator
*/
final class RuntimeException extends \RuntimeException implements Exception
{
}