upgrade to laravel 8.x
This commit is contained in:
+29
-11
@@ -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.
|
||||
*/
|
||||
@@ -26,9 +34,9 @@ class NumericComparator extends ScalarComparator
|
||||
{
|
||||
// all numerical values, but not if one of them is a double
|
||||
// or both of them are strings
|
||||
return \is_numeric($expected) && \is_numeric($actual) &&
|
||||
!(\is_float($expected) || \is_float($actual)) &&
|
||||
!(\is_string($expected) && \is_string($actual));
|
||||
return is_numeric($expected) && is_numeric($actual) &&
|
||||
!(is_float($expected) || is_float($actual)) &&
|
||||
!(is_string($expected) && is_string($actual));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,22 +50,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)
|
||||
@@ -65,4 +73,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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user