upgraded dependencies
This commit is contained in:
63
vendor/sebastian/comparator/ChangeLog.md
vendored
63
vendor/sebastian/comparator/ChangeLog.md
vendored
@@ -2,6 +2,60 @@
|
||||
|
||||
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
|
||||
|
||||
## [4.0.8] - 2022-09-14
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#102](https://github.com/sebastianbergmann/comparator/pull/102): Fix `float` comparison precision
|
||||
|
||||
## [4.0.7] - 2022-09-14
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#99](https://github.com/sebastianbergmann/comparator/pull/99): Fix weak comparison between `'0'` and `false`
|
||||
|
||||
## [4.0.6] - 2020-10-26
|
||||
|
||||
### Fixed
|
||||
|
||||
* `SebastianBergmann\Comparator\Exception` now correctly extends `\Throwable`
|
||||
|
||||
## [4.0.5] - 2020-09-30
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#89](https://github.com/sebastianbergmann/comparator/pull/89): Handle PHP 8 `ValueError`
|
||||
|
||||
## [4.0.4] - 2020-09-28
|
||||
|
||||
### Changed
|
||||
|
||||
* Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`
|
||||
|
||||
## [4.0.3] - 2020-06-26
|
||||
|
||||
### Added
|
||||
|
||||
* This component is now supported on PHP 8
|
||||
|
||||
## [4.0.2] - 2020-06-15
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#85](https://github.com/sebastianbergmann/comparator/issues/85): Version 4.0.1 breaks backward compatibility
|
||||
|
||||
## [4.0.1] - 2020-06-15
|
||||
|
||||
### Changed
|
||||
|
||||
* Tests etc. are now ignored for archive exports
|
||||
|
||||
## [4.0.0] - 2020-02-07
|
||||
|
||||
### Removed
|
||||
|
||||
* Removed support for PHP 7.1 and PHP 7.2
|
||||
|
||||
## [3.0.5] - 2022-09-14
|
||||
|
||||
### Fixed
|
||||
@@ -68,6 +122,15 @@ 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`
|
||||
|
||||
[4.0.8]: https://github.com/sebastianbergmann/comparator/compare/4.0.7...4.0.8
|
||||
[4.0.7]: https://github.com/sebastianbergmann/comparator/compare/4.0.6...4.0.7
|
||||
[4.0.6]: https://github.com/sebastianbergmann/comparator/compare/4.0.5...4.0.6
|
||||
[4.0.5]: https://github.com/sebastianbergmann/comparator/compare/4.0.4...4.0.5
|
||||
[4.0.4]: https://github.com/sebastianbergmann/comparator/compare/4.0.3...4.0.4
|
||||
[4.0.3]: https://github.com/sebastianbergmann/comparator/compare/4.0.2...4.0.3
|
||||
[4.0.2]: https://github.com/sebastianbergmann/comparator/compare/4.0.1...4.0.2
|
||||
[4.0.1]: https://github.com/sebastianbergmann/comparator/compare/4.0.0...4.0.1
|
||||
[4.0.0]: https://github.com/sebastianbergmann/comparator/compare/3.0.5...4.0.0
|
||||
[3.0.5]: https://github.com/sebastianbergmann/comparator/compare/3.0.4...3.0.5
|
||||
[3.0.4]: https://github.com/sebastianbergmann/comparator/compare/3.0.3...3.0.4
|
||||
[3.0.3]: https://github.com/sebastianbergmann/comparator/compare/3.0.2...3.0.3
|
||||
|
||||
2
vendor/sebastian/comparator/LICENSE
vendored
2
vendor/sebastian/comparator/LICENSE
vendored
@@ -1,6 +1,6 @@
|
||||
Comparator
|
||||
|
||||
Copyright (c) 2002-2018, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
Copyright (c) 2002-2020, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
14
vendor/sebastian/comparator/README.md
vendored
14
vendor/sebastian/comparator/README.md
vendored
@@ -1,6 +1,7 @@
|
||||
[](https://travis-ci.org/sebastianbergmann/comparator)
|
||||
# sebastian/comparator
|
||||
|
||||
# Comparator
|
||||
[](https://github.com/sebastianbergmann/comparator/actions)
|
||||
[](https://shepherd.dev/github/sebastianbergmann/comparator)
|
||||
|
||||
This component provides the functionality to compare PHP values for equality.
|
||||
|
||||
@@ -8,11 +9,15 @@ This component provides the functionality to compare PHP values for equality.
|
||||
|
||||
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
|
||||
|
||||
composer require sebastian/comparator
|
||||
```
|
||||
composer require sebastian/comparator
|
||||
```
|
||||
|
||||
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
|
||||
|
||||
composer require --dev sebastian/comparator
|
||||
```
|
||||
composer require --dev sebastian/comparator
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -34,4 +39,3 @@ try {
|
||||
print "Dates don't match";
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
13
vendor/sebastian/comparator/composer.json
vendored
13
vendor/sebastian/comparator/composer.json
vendored
@@ -24,14 +24,17 @@
|
||||
],
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"php": ">=7.1",
|
||||
"sebastian/diff": "^3.0",
|
||||
"sebastian/exporter": "^3.1"
|
||||
"php": ">=7.3",
|
||||
"sebastian/diff": "^4.0",
|
||||
"sebastian/exporter": "^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.5"
|
||||
"phpunit/phpunit": "^9.3"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.3.0"
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true
|
||||
},
|
||||
@@ -47,7 +50,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
"dev-master": "4.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,8 +9,19 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use function array_key_exists;
|
||||
use function is_array;
|
||||
use function sort;
|
||||
use function sprintf;
|
||||
use function str_replace;
|
||||
use function trim;
|
||||
|
||||
/**
|
||||
* Compares arrays for equality.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
class ArrayComparator extends Comparator
|
||||
{
|
||||
@@ -24,11 +35,11 @@ class ArrayComparator extends Comparator
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return \is_array($expected) && \is_array($actual);
|
||||
return is_array($expected) && is_array($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that two values are equal.
|
||||
* Asserts that two arrays are equal.
|
||||
*
|
||||
* @param mixed $expected First value to compare
|
||||
* @param mixed $actual Second value to compare
|
||||
@@ -39,11 +50,11 @@ class ArrayComparator extends Comparator
|
||||
*
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])/*: void*/
|
||||
{
|
||||
if ($canonicalize) {
|
||||
\sort($expected);
|
||||
\sort($actual);
|
||||
sort($expected);
|
||||
sort($actual);
|
||||
}
|
||||
|
||||
$remaining = $actual;
|
||||
@@ -54,8 +65,8 @@ class ArrayComparator extends Comparator
|
||||
foreach ($expected as $key => $value) {
|
||||
unset($remaining[$key]);
|
||||
|
||||
if (!\array_key_exists($key, $actual)) {
|
||||
$expectedAsString .= \sprintf(
|
||||
if (!array_key_exists($key, $actual)) {
|
||||
$expectedAsString .= sprintf(
|
||||
" %s => %s\n",
|
||||
$this->exporter->export($key),
|
||||
$this->exporter->shortenedExport($value)
|
||||
@@ -70,25 +81,25 @@ class ArrayComparator extends Comparator
|
||||
$comparator = $this->factory->getComparatorFor($value, $actual[$key]);
|
||||
$comparator->assertEquals($value, $actual[$key], $delta, $canonicalize, $ignoreCase, $processed);
|
||||
|
||||
$expectedAsString .= \sprintf(
|
||||
$expectedAsString .= sprintf(
|
||||
" %s => %s\n",
|
||||
$this->exporter->export($key),
|
||||
$this->exporter->shortenedExport($value)
|
||||
);
|
||||
|
||||
$actualAsString .= \sprintf(
|
||||
$actualAsString .= sprintf(
|
||||
" %s => %s\n",
|
||||
$this->exporter->export($key),
|
||||
$this->exporter->shortenedExport($actual[$key])
|
||||
);
|
||||
} catch (ComparisonFailure $e) {
|
||||
$expectedAsString .= \sprintf(
|
||||
$expectedAsString .= sprintf(
|
||||
" %s => %s\n",
|
||||
$this->exporter->export($key),
|
||||
$e->getExpectedAsString() ? $this->indent($e->getExpectedAsString()) : $this->exporter->shortenedExport($e->getExpected())
|
||||
);
|
||||
|
||||
$actualAsString .= \sprintf(
|
||||
$actualAsString .= sprintf(
|
||||
" %s => %s\n",
|
||||
$this->exporter->export($key),
|
||||
$e->getActualAsString() ? $this->indent($e->getActualAsString()) : $this->exporter->shortenedExport($e->getActual())
|
||||
@@ -99,7 +110,7 @@ class ArrayComparator extends Comparator
|
||||
}
|
||||
|
||||
foreach ($remaining as $key => $value) {
|
||||
$actualAsString .= \sprintf(
|
||||
$actualAsString .= sprintf(
|
||||
" %s => %s\n",
|
||||
$this->exporter->export($key),
|
||||
$this->exporter->shortenedExport($value)
|
||||
@@ -125,6 +136,6 @@ class ArrayComparator extends Comparator
|
||||
|
||||
protected function indent($lines)
|
||||
{
|
||||
return \trim(\str_replace("\n", "\n ", $lines));
|
||||
return trim(str_replace("\n", "\n ", $lines));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -31,7 +31,7 @@ abstract class Comparator
|
||||
$this->exporter = new Exporter;
|
||||
}
|
||||
|
||||
public function setFactory(Factory $factory)
|
||||
public function setFactory(Factory $factory)/*: void*/
|
||||
{
|
||||
$this->factory = $factory;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,13 +9,14 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use RuntimeException;
|
||||
use SebastianBergmann\Diff\Differ;
|
||||
use SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder;
|
||||
|
||||
/**
|
||||
* Thrown when an assertion for string equality failed.
|
||||
*/
|
||||
class ComparisonFailure extends \RuntimeException
|
||||
class ComparisonFailure extends RuntimeException
|
||||
{
|
||||
/**
|
||||
* Expected value of the retrieval which does not match $actual.
|
||||
@@ -32,14 +33,14 @@ class ComparisonFailure extends \RuntimeException
|
||||
protected $actual;
|
||||
|
||||
/**
|
||||
* The string representation of the expected value
|
||||
* The string representation of the expected value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $expectedAsString;
|
||||
|
||||
/**
|
||||
* The string representation of the actual value
|
||||
* The string representation of the actual value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,8 +9,11 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use function sprintf;
|
||||
use function strtolower;
|
||||
use DOMDocument;
|
||||
use DOMNode;
|
||||
use ValueError;
|
||||
|
||||
/**
|
||||
* Compares DOMNode instances for equality.
|
||||
@@ -42,7 +45,7 @@ class DOMNodeComparator extends ObjectComparator
|
||||
*
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])/*: void*/
|
||||
{
|
||||
$expectedAsString = $this->nodeToText($expected, true, $ignoreCase);
|
||||
$actualAsString = $this->nodeToText($actual, true, $ignoreCase);
|
||||
@@ -56,7 +59,7 @@ class DOMNodeComparator extends ObjectComparator
|
||||
$expectedAsString,
|
||||
$actualAsString,
|
||||
false,
|
||||
\sprintf("Failed asserting that two DOM %s are equal.\n", $type)
|
||||
sprintf("Failed asserting that two DOM %s are equal.\n", $type)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -69,7 +72,11 @@ class DOMNodeComparator extends ObjectComparator
|
||||
{
|
||||
if ($canonicalize) {
|
||||
$document = new DOMDocument;
|
||||
@$document->loadXML($node->C14N());
|
||||
|
||||
try {
|
||||
@$document->loadXML($node->C14N());
|
||||
} catch (ValueError $e) {
|
||||
}
|
||||
|
||||
$node = $document;
|
||||
}
|
||||
@@ -81,6 +88,6 @@ class DOMNodeComparator extends ObjectComparator
|
||||
|
||||
$text = $node instanceof DOMDocument ? $node->saveXML() : $document->saveXML($node);
|
||||
|
||||
return $ignoreCase ? \strtolower($text) : $text;
|
||||
return $ignoreCase ? strtolower($text) : $text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,6 +9,15 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use function abs;
|
||||
use function floor;
|
||||
use function sprintf;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
use DateTimeZone;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Compares DateTimeInterface instances for equality.
|
||||
*/
|
||||
@@ -24,8 +33,8 @@ class DateTimeComparator extends ObjectComparator
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return ($expected instanceof \DateTime || $expected instanceof \DateTimeInterface) &&
|
||||
($actual instanceof \DateTime || $actual instanceof \DateTimeInterface);
|
||||
return ($expected instanceof DateTime || $expected instanceof DateTimeInterface) &&
|
||||
($actual instanceof DateTime || $actual instanceof DateTimeInterface);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,26 +47,26 @@ class DateTimeComparator extends ObjectComparator
|
||||
* @param bool $ignoreCase Case is ignored when set to true
|
||||
* @param array $processed List of already processed elements (used to prevent infinite recursion)
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])/*: void*/
|
||||
{
|
||||
/** @var \DateTimeInterface $expected */
|
||||
/** @var \DateTimeInterface $actual */
|
||||
$absDelta = \abs($delta);
|
||||
$delta = new \DateInterval(\sprintf('PT%dS', $absDelta));
|
||||
$delta->f = $absDelta - \floor($absDelta);
|
||||
/** @var DateTimeInterface $expected */
|
||||
/** @var DateTimeInterface $actual */
|
||||
$absDelta = abs($delta);
|
||||
$delta = new DateInterval(sprintf('PT%dS', $absDelta));
|
||||
$delta->f = $absDelta - floor($absDelta);
|
||||
|
||||
$actualClone = (clone $actual)
|
||||
->setTimezone(new \DateTimeZone('UTC'));
|
||||
->setTimezone(new DateTimeZone('UTC'));
|
||||
|
||||
$expectedLower = (clone $expected)
|
||||
->setTimezone(new \DateTimeZone('UTC'))
|
||||
->setTimezone(new DateTimeZone('UTC'))
|
||||
->sub($delta);
|
||||
|
||||
$expectedUpper = (clone $expected)
|
||||
->setTimezone(new \DateTimeZone('UTC'))
|
||||
->setTimezone(new DateTimeZone('UTC'))
|
||||
->add($delta);
|
||||
|
||||
if ($actualClone < $expectedLower || $actualClone > $expectedUpper) {
|
||||
@@ -77,7 +86,7 @@ class DateTimeComparator extends ObjectComparator
|
||||
* 'Invalid DateTimeInterface object' if the provided DateTimeInterface was not properly
|
||||
* initialized.
|
||||
*/
|
||||
private function dateTimeToString(\DateTimeInterface $datetime): string
|
||||
private function dateTimeToString(DateTimeInterface $datetime): string
|
||||
{
|
||||
$string = $datetime->format('Y-m-d\TH:i:s.uO');
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,6 +9,9 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use function is_float;
|
||||
use function is_numeric;
|
||||
|
||||
/**
|
||||
* Compares doubles for equality.
|
||||
*
|
||||
@@ -21,7 +24,7 @@ class DoubleComparator extends NumericComparator
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
const EPSILON = 0.0000000001;
|
||||
public const EPSILON = 0.0000000001;
|
||||
|
||||
/**
|
||||
* Returns whether the comparator can compare two values.
|
||||
@@ -33,7 +36,7 @@ class DoubleComparator extends NumericComparator
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return (\is_float($expected) || \is_float($actual)) && \is_numeric($expected) && \is_numeric($actual);
|
||||
return (is_float($expected) || is_float($actual)) && is_numeric($expected) && is_numeric($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +50,7 @@ class DoubleComparator extends NumericComparator
|
||||
*
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)/*: void*/
|
||||
{
|
||||
if ($delta == 0) {
|
||||
$delta = self::EPSILON;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Compares Exception instances for equality.
|
||||
*/
|
||||
@@ -24,7 +26,7 @@ class ExceptionComparator extends ObjectComparator
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return $expected instanceof \Exception && $actual instanceof \Exception;
|
||||
return $expected instanceof Exception && $actual instanceof Exception;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
20
vendor/sebastian/comparator/src/Factory.php
vendored
20
vendor/sebastian/comparator/src/Factory.php
vendored
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use function array_unshift;
|
||||
|
||||
/**
|
||||
* Factory for comparators which compare values for equality.
|
||||
*/
|
||||
@@ -35,7 +37,7 @@ class Factory
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$instance === null) {
|
||||
self::$instance = new self;
|
||||
self::$instance = new self; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
@@ -70,6 +72,8 @@ class Factory
|
||||
return $comparator;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException('No suitable Comparator implementation found');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,9 +86,9 @@ class Factory
|
||||
*
|
||||
* @param Comparator $comparator The comparator to be registered
|
||||
*/
|
||||
public function register(Comparator $comparator)
|
||||
public function register(Comparator $comparator)/*: void*/
|
||||
{
|
||||
\array_unshift($this->customComparators, $comparator);
|
||||
array_unshift($this->customComparators, $comparator);
|
||||
|
||||
$comparator->setFactory($this);
|
||||
}
|
||||
@@ -96,7 +100,7 @@ class Factory
|
||||
*
|
||||
* @param Comparator $comparator The comparator to be unregistered
|
||||
*/
|
||||
public function unregister(Comparator $comparator)
|
||||
public function unregister(Comparator $comparator)/*: void*/
|
||||
{
|
||||
foreach ($this->customComparators as $key => $_comparator) {
|
||||
if ($comparator === $_comparator) {
|
||||
@@ -108,12 +112,12 @@ class Factory
|
||||
/**
|
||||
* Unregisters all non-default comparators.
|
||||
*/
|
||||
public function reset()
|
||||
public function reset()/*: void*/
|
||||
{
|
||||
$this->customComparators = [];
|
||||
}
|
||||
|
||||
private function registerDefaultComparators()
|
||||
private function registerDefaultComparators(): void
|
||||
{
|
||||
$this->registerDefaultComparator(new MockObjectComparator);
|
||||
$this->registerDefaultComparator(new DateTimeComparator);
|
||||
@@ -128,7 +132,7 @@ class Factory
|
||||
$this->registerDefaultComparator(new TypeComparator);
|
||||
}
|
||||
|
||||
private function registerDefaultComparator(Comparator $comparator)
|
||||
private function registerDefaultComparator(Comparator $comparator): void
|
||||
{
|
||||
$this->defaultComparators[] = $comparator;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,8 +9,10 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
/**
|
||||
* Compares PHPUnit_Framework_MockObject_MockObject instances for equality.
|
||||
* Compares PHPUnit\Framework\MockObject\MockObject instances for equality.
|
||||
*/
|
||||
class MockObjectComparator extends ObjectComparator
|
||||
{
|
||||
@@ -24,8 +26,7 @@ class MockObjectComparator extends ObjectComparator
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return ($expected instanceof \PHPUnit_Framework_MockObject_MockObject || $expected instanceof \PHPUnit\Framework\MockObject\MockObject) &&
|
||||
($actual instanceof \PHPUnit_Framework_MockObject_MockObject || $actual instanceof \PHPUnit\Framework\MockObject\MockObject);
|
||||
return $expected instanceof MockObject && $actual instanceof MockObject;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,6 +9,14 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use function abs;
|
||||
use function is_float;
|
||||
use function is_infinite;
|
||||
use function is_nan;
|
||||
use function is_numeric;
|
||||
use function is_string;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Compares numerical values for equality.
|
||||
*/
|
||||
@@ -25,8 +33,8 @@ class NumericComparator extends ScalarComparator
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
// all numerical values, but not if both of them are strings
|
||||
return \is_numeric($expected) && \is_numeric($actual) &&
|
||||
!(\is_string($expected) && \is_string($actual));
|
||||
return is_numeric($expected) && is_numeric($actual) &&
|
||||
!(is_string($expected) && is_string($actual));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,22 +48,22 @@ class NumericComparator extends ScalarComparator
|
||||
*
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)/*: void*/
|
||||
{
|
||||
if (\is_infinite($actual) && \is_infinite($expected)) {
|
||||
return; // @codeCoverageIgnore
|
||||
if ($this->isInfinite($actual) && $this->isInfinite($expected)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((\is_infinite($actual) xor \is_infinite($expected)) ||
|
||||
(\is_nan($actual) || \is_nan($expected)) ||
|
||||
\abs($actual - $expected) > $delta) {
|
||||
if (($this->isInfinite($actual) xor $this->isInfinite($expected)) ||
|
||||
($this->isNan($actual) || $this->isNan($expected)) ||
|
||||
abs($actual - $expected) > $delta) {
|
||||
throw new ComparisonFailure(
|
||||
$expected,
|
||||
$actual,
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
\sprintf(
|
||||
sprintf(
|
||||
'Failed asserting that %s matches expected %s.',
|
||||
$this->exporter->export($actual),
|
||||
$this->exporter->export($expected)
|
||||
@@ -63,4 +71,14 @@ class NumericComparator extends ScalarComparator
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function isInfinite($value): bool
|
||||
{
|
||||
return is_float($value) && is_infinite($value);
|
||||
}
|
||||
|
||||
private function isNan($value): bool
|
||||
{
|
||||
return is_float($value) && is_nan($value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,6 +9,12 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use function get_class;
|
||||
use function in_array;
|
||||
use function is_object;
|
||||
use function sprintf;
|
||||
use function substr_replace;
|
||||
|
||||
/**
|
||||
* Compares objects for equality.
|
||||
*/
|
||||
@@ -24,7 +30,7 @@ class ObjectComparator extends ArrayComparator
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return \is_object($expected) && \is_object($actual);
|
||||
return is_object($expected) && is_object($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,26 +45,26 @@ class ObjectComparator extends ArrayComparator
|
||||
*
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])/*: void*/
|
||||
{
|
||||
if (\get_class($actual) !== \get_class($expected)) {
|
||||
if (get_class($actual) !== get_class($expected)) {
|
||||
throw new ComparisonFailure(
|
||||
$expected,
|
||||
$actual,
|
||||
$this->exporter->export($expected),
|
||||
$this->exporter->export($actual),
|
||||
false,
|
||||
\sprintf(
|
||||
sprintf(
|
||||
'%s is not instance of expected class "%s".',
|
||||
$this->exporter->export($actual),
|
||||
\get_class($expected)
|
||||
get_class($expected)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// don't compare twice to allow for cyclic dependencies
|
||||
if (\in_array([$actual, $expected], $processed, true) ||
|
||||
\in_array([$expected, $actual], $processed, true)) {
|
||||
if (in_array([$actual, $expected], $processed, true) ||
|
||||
in_array([$expected, $actual], $processed, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,8 +88,8 @@ class ObjectComparator extends ArrayComparator
|
||||
$expected,
|
||||
$actual,
|
||||
// replace "Array" with "MyClass object"
|
||||
\substr_replace($e->getExpectedAsString(), \get_class($expected) . ' Object', 0, 5),
|
||||
\substr_replace($e->getActualAsString(), \get_class($actual) . ' Object', 0, 5),
|
||||
substr_replace($e->getExpectedAsString(), get_class($expected) . ' Object', 0, 5),
|
||||
substr_replace($e->getActualAsString(), get_class($actual) . ' Object', 0, 5),
|
||||
false,
|
||||
'Failed asserting that two objects are equal.'
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use function is_resource;
|
||||
|
||||
/**
|
||||
* Compares resources for equality.
|
||||
*/
|
||||
@@ -24,7 +26,7 @@ class ResourceComparator extends Comparator
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return \is_resource($expected) && \is_resource($actual);
|
||||
return is_resource($expected) && is_resource($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +40,7 @@ class ResourceComparator extends Comparator
|
||||
*
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)/*: void*/
|
||||
{
|
||||
if ($actual != $expected) {
|
||||
throw new ComparisonFailure(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,6 +9,14 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use function is_bool;
|
||||
use function is_object;
|
||||
use function is_scalar;
|
||||
use function is_string;
|
||||
use function method_exists;
|
||||
use function sprintf;
|
||||
use function strtolower;
|
||||
|
||||
/**
|
||||
* Compares scalar or NULL values for equality.
|
||||
*/
|
||||
@@ -26,11 +34,11 @@ class ScalarComparator extends Comparator
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return ((\is_scalar($expected) xor null === $expected) &&
|
||||
(\is_scalar($actual) xor null === $actual))
|
||||
return ((is_scalar($expected) xor null === $expected) &&
|
||||
(is_scalar($actual) xor null === $actual))
|
||||
// allow comparison between strings and objects featuring __toString()
|
||||
|| (\is_string($expected) && \is_object($actual) && \method_exists($actual, '__toString'))
|
||||
|| (\is_object($expected) && \method_exists($expected, '__toString') && \is_string($actual));
|
||||
|| (is_string($expected) && is_object($actual) && method_exists($actual, '__toString'))
|
||||
|| (is_object($expected) && method_exists($expected, '__toString') && is_string($actual));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,24 +52,24 @@ class ScalarComparator extends Comparator
|
||||
*
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)/*: void*/
|
||||
{
|
||||
$expectedToCompare = $expected;
|
||||
$actualToCompare = $actual;
|
||||
|
||||
// always compare as strings to avoid strange behaviour
|
||||
// otherwise 0 == 'Foobar'
|
||||
if ((\is_string($expected) && !\is_bool($actual)) || (\is_string($actual) && !\is_bool($expected))) {
|
||||
if ((is_string($expected) && !is_bool($actual)) || (is_string($actual) && !is_bool($expected))) {
|
||||
$expectedToCompare = (string) $expectedToCompare;
|
||||
$actualToCompare = (string) $actualToCompare;
|
||||
|
||||
if ($ignoreCase) {
|
||||
$expectedToCompare = \strtolower($expectedToCompare);
|
||||
$actualToCompare = \strtolower($actualToCompare);
|
||||
$expectedToCompare = strtolower($expectedToCompare);
|
||||
$actualToCompare = strtolower($actualToCompare);
|
||||
}
|
||||
}
|
||||
|
||||
if ($expectedToCompare !== $actualToCompare && \is_string($expected) && \is_string($actual)) {
|
||||
if ($expectedToCompare !== $actualToCompare && is_string($expected) && is_string($actual)) {
|
||||
throw new ComparisonFailure(
|
||||
$expected,
|
||||
$actual,
|
||||
@@ -80,7 +88,7 @@ class ScalarComparator extends Comparator
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
\sprintf(
|
||||
sprintf(
|
||||
'Failed asserting that %s matches expected %s.',
|
||||
$this->exporter->export($actual),
|
||||
$this->exporter->export($expected)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use SplObjectStorage;
|
||||
|
||||
/**
|
||||
* Compares \SplObjectStorage instances for equality.
|
||||
*/
|
||||
@@ -24,7 +26,7 @@ class SplObjectStorageComparator extends Comparator
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return $expected instanceof \SplObjectStorage && $actual instanceof \SplObjectStorage;
|
||||
return $expected instanceof SplObjectStorage && $actual instanceof SplObjectStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +40,7 @@ class SplObjectStorageComparator extends Comparator
|
||||
*
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)/*: void*/
|
||||
{
|
||||
foreach ($actual as $object) {
|
||||
if (!$expected->contains($object)) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
@@ -9,6 +9,9 @@
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use function gettype;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Compares values for type equality.
|
||||
*/
|
||||
@@ -38,9 +41,9 @@ class TypeComparator extends Comparator
|
||||
*
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)/*: void*/
|
||||
{
|
||||
if (\gettype($expected) != \gettype($actual)) {
|
||||
if (gettype($expected) != gettype($actual)) {
|
||||
throw new ComparisonFailure(
|
||||
$expected,
|
||||
$actual,
|
||||
@@ -48,10 +51,10 @@ class TypeComparator extends Comparator
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
\sprintf(
|
||||
sprintf(
|
||||
'%s does not match expected type "%s".',
|
||||
$this->exporter->shortenedExport($actual),
|
||||
\gettype($expected)
|
||||
gettype($expected)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
16
vendor/sebastian/comparator/src/exceptions/Exception.php
vendored
Normal file
16
vendor/sebastian/comparator/src/exceptions/Exception.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use Throwable;
|
||||
|
||||
interface Exception extends Throwable
|
||||
{
|
||||
}
|
||||
14
vendor/sebastian/comparator/src/exceptions/RuntimeException.php
vendored
Normal file
14
vendor/sebastian/comparator/src/exceptions/RuntimeException.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
final class RuntimeException extends \RuntimeException implements Exception
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user