diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index a3f21745..ea87b41d 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -194,7 +194,7 @@ jobs: - name: "Downgrade brick/math in lock file, to test compatibility with older versions" run: | - composer update brick/math:"0.11.0" + composer update brick/math:"0.14.2" - name: "Install dependencies (Composer)" uses: "ramsey/composer-install@v3" diff --git a/composer.json b/composer.json index cb4422dd..eb04a050 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ ], "require": { "php": "^8.2", - "brick/math": "^0.11 || ^0.12 || ^0.13 || ^0.14" + "brick/math": "^0.14.2 || ^0.15 || ^0.16 || ^0.17" }, "require-dev": { "captainhook/captainhook": "^5.25", diff --git a/src/Math/BrickMathCalculator.php b/src/Math/BrickMathCalculator.php index 57bbabe4..b18d35aa 100644 --- a/src/Math/BrickMathCalculator.php +++ b/src/Math/BrickMathCalculator.php @@ -32,16 +32,16 @@ final class BrickMathCalculator implements CalculatorInterface { private const ROUNDING_MODE_MAP = [ - RoundingMode::UNNECESSARY => BrickMathRounding::UNNECESSARY, - RoundingMode::UP => BrickMathRounding::UP, - RoundingMode::DOWN => BrickMathRounding::DOWN, - RoundingMode::CEILING => BrickMathRounding::CEILING, - RoundingMode::FLOOR => BrickMathRounding::FLOOR, - RoundingMode::HALF_UP => BrickMathRounding::HALF_UP, - RoundingMode::HALF_DOWN => BrickMathRounding::HALF_DOWN, - RoundingMode::HALF_CEILING => BrickMathRounding::HALF_CEILING, - RoundingMode::HALF_FLOOR => BrickMathRounding::HALF_FLOOR, - RoundingMode::HALF_EVEN => BrickMathRounding::HALF_EVEN, + RoundingMode::UNNECESSARY => BrickMathRounding::Unnecessary, + RoundingMode::UP => BrickMathRounding::Up, + RoundingMode::DOWN => BrickMathRounding::Down, + RoundingMode::CEILING => BrickMathRounding::Ceiling, + RoundingMode::FLOOR => BrickMathRounding::Floor, + RoundingMode::HALF_UP => BrickMathRounding::HalfUp, + RoundingMode::HALF_DOWN => BrickMathRounding::HalfDown, + RoundingMode::HALF_CEILING => BrickMathRounding::HalfCeiling, + RoundingMode::HALF_FLOOR => BrickMathRounding::HalfFloor, + RoundingMode::HALF_EVEN => BrickMathRounding::HalfEven, ]; public function add(NumberInterface $augend, NumberInterface ...$addends): NumberInterface @@ -145,11 +145,9 @@ public function toInteger(Hexadecimal $value): IntegerObject /** * Maps ramsey/uuid rounding modes to those used by brick/math - * - * @return BrickMathRounding::* */ - private function getBrickRoundingMode(int $roundingMode) + private function getBrickRoundingMode(int $roundingMode): BrickMathRounding { - return self::ROUNDING_MODE_MAP[$roundingMode] ?? BrickMathRounding::UNNECESSARY; + return self::ROUNDING_MODE_MAP[$roundingMode] ?? BrickMathRounding::Unnecessary; } } diff --git a/src/Type/Time.php b/src/Type/Time.php index b2061dac..8a6fe01e 100644 --- a/src/Type/Time.php +++ b/src/Type/Time.php @@ -63,9 +63,10 @@ public function toString(): string { /** @var numeric-string $microseconds */ $microseconds = sprintf('%06s', $this->microseconds->toString()); + /** @var numeric-string $time */ + $time = "{$this->seconds->toString()}.$microseconds"; - /** @var numeric-string */ - return "{$this->seconds->toString()}.$microseconds"; + return $time; } /** diff --git a/tests/Converter/Time/PhpTimeConverterTest.php b/tests/Converter/Time/PhpTimeConverterTest.php index 55ae249d..5c7010d6 100644 --- a/tests/Converter/Time/PhpTimeConverterTest.php +++ b/tests/Converter/Time/PhpTimeConverterTest.php @@ -38,10 +38,10 @@ public function testCalculateTimeReturnsArrayOfTimeSegments(): void $converter = new PhpTimeConverter(); - /** @var numeric-string $numericSeconds */ + /** @var non-empty-string&numeric-string $numericSeconds */ $numericSeconds = (string) $seconds; - /** @var numeric-string $numericMicroseconds */ + /** @var non-empty-string&numeric-string $numericMicroseconds */ $numericMicroseconds = (string) $microseconds; $returned = $converter->calculateTime($numericSeconds, $numericMicroseconds); diff --git a/tests/Math/BrickMathCalculatorTest.php b/tests/Math/BrickMathCalculatorTest.php index 8cb5d906..e4e55fac 100644 --- a/tests/Math/BrickMathCalculatorTest.php +++ b/tests/Math/BrickMathCalculatorTest.php @@ -96,7 +96,9 @@ public function testFromBaseThrowsException(): void $calculator = new BrickMathCalculator(); $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('"o" is not a valid character in base 16'); + $this->expectExceptionMessageMatches( + '/(\"o\" is not a valid character in base 16\.|Character \"o\" is not valid in base 16\.)/' + ); $calculator->fromBase('foobar', 16); } diff --git a/tests/UuidTest.php b/tests/UuidTest.php index f83e163c..eecde237 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -1051,8 +1051,8 @@ public function test32BitMatch64BitForOneHourPeriod(): void ); // Assert that the time matches - $usecAdd = BigDecimal::of($usec)->dividedBy('1000000', 14, RoundingMode::HALF_UP); - $testTime = BigDecimal::of($currentTime)->plus($usecAdd)->toScale(0, RoundingMode::DOWN); + $usecAdd = BigDecimal::of($usec)->dividedBy('1000000', 14, RoundingMode::HalfUp); + $testTime = BigDecimal::of($currentTime)->plus($usecAdd)->toScale(0, RoundingMode::Down); $this->assertSame((string) $testTime, (string) $uuid64->getDateTime()->getTimestamp()); $this->assertSame((string) $testTime, (string) $uuid32->getDateTime()->getTimestamp()); }