Update brick/math for static analysis but downgrade in tests for PHP 8.0

This commit is contained in:
Ben Ramsey
2025-12-13 20:19:54 -06:00
parent 4618169496
commit bec7176b05
3 changed files with 29 additions and 35 deletions
@@ -194,6 +194,10 @@ jobs:
coverage: "none"
ini-values: "memory_limit=-1"
- name: "Downgrade brick/math in lock file for PHP 8.0"
run: |
composer update brick/math:"0.8.8"
- name: "Install dependencies (Composer)"
uses: "ramsey/composer-install@v3"
with:
Generated
+19 -24
View File
@@ -8,26 +8,25 @@
"packages": [
{
"name": "brick/math",
"version": "0.9.3",
"version": "0.14.1",
"source": {
"type": "git",
"url": "https://github.com/brick/math.git",
"reference": "ca57d18f028f84f777b2168cd1911b0dee2343ae"
"reference": "f05858549e5f9d7bb45875a75583240a38a281d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/brick/math/zipball/ca57d18f028f84f777b2168cd1911b0dee2343ae",
"reference": "ca57d18f028f84f777b2168cd1911b0dee2343ae",
"url": "https://api.github.com/repos/brick/math/zipball/f05858549e5f9d7bb45875a75583240a38a281d0",
"reference": "f05858549e5f9d7bb45875a75583240a38a281d0",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^7.1 || ^8.0"
"php": "^8.2"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^7.5.15 || ^8.5 || ^9.0",
"vimeo/psalm": "4.9.2"
"phpstan/phpstan": "2.1.22",
"phpunit/phpunit": "^11.5"
},
"type": "library",
"autoload": {
@@ -47,24 +46,25 @@
"arithmetic",
"bigdecimal",
"bignum",
"bignumber",
"brick",
"math"
"decimal",
"integer",
"math",
"mathematics",
"rational"
],
"support": {
"issues": "https://github.com/brick/math/issues",
"source": "https://github.com/brick/math/tree/0.9.3"
"source": "https://github.com/brick/math/tree/0.14.1"
},
"funding": [
{
"url": "https://github.com/BenMorel",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/brick/math",
"type": "tidelift"
}
],
"time": "2021-08-15T20:50:18+00:00"
"time": "2025-11-24T14:40:29+00:00"
},
{
"name": "ramsey/collection",
@@ -2633,16 +2633,11 @@
},
{
"name": "phpstan/phpstan",
"version": "2.1.22",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "41600c8379eb5aee63e9413fe9e97273e25d57e4"
},
"version": "2.1.33",
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/41600c8379eb5aee63e9413fe9e97273e25d57e4",
"reference": "41600c8379eb5aee63e9413fe9e97273e25d57e4",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/9e800e6bee7d5bd02784d4c6069b48032d16224f",
"reference": "9e800e6bee7d5bd02784d4c6069b48032d16224f",
"shasum": ""
},
"require": {
@@ -2687,7 +2682,7 @@
"type": "github"
}
],
"time": "2025-08-04T19:17:37+00:00"
"time": "2025-12-05T10:24:31+00:00"
},
{
"name": "phpstan/phpstan-mockery",
+6 -11
View File
@@ -49,11 +49,10 @@ final class BrickMathCalculator implements CalculatorInterface
$sum = BigInteger::of($augend->toString());
foreach ($addends as $addend) {
/** @phpstan-ignore possiblyImpure.methodCall */
$sum = $sum->plus($addend->toString());
}
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall */
/** @phpstan-ignore possiblyImpure.new */
return new IntegerObject((string) $sum);
}
@@ -62,11 +61,10 @@ final class BrickMathCalculator implements CalculatorInterface
$difference = BigInteger::of($minuend->toString());
foreach ($subtrahends as $subtrahend) {
/** @phpstan-ignore possiblyImpure.methodCall */
$difference = $difference->minus($subtrahend->toString());
}
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall */
/** @phpstan-ignore possiblyImpure.new */
return new IntegerObject((string) $difference);
}
@@ -75,11 +73,10 @@ final class BrickMathCalculator implements CalculatorInterface
$product = BigInteger::of($multiplicand->toString());
foreach ($multipliers as $multiplier) {
/** @phpstan-ignore possiblyImpure.methodCall */
$product = $product->multipliedBy($multiplier->toString());
}
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall */
/** @phpstan-ignore possiblyImpure.new */
return new IntegerObject((string) $product);
}
@@ -95,23 +92,22 @@ final class BrickMathCalculator implements CalculatorInterface
$quotient = BigDecimal::of($dividend->toString());
foreach ($divisors as $divisor) {
/** @phpstan-ignore possiblyImpure.methodCall */
$quotient = $quotient->dividedBy($divisor->toString(), $scale, $brickRounding);
}
if ($scale === 0) {
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall, possiblyImpure.methodCall */
/** @phpstan-ignore possiblyImpure.new */
return new IntegerObject((string) $quotient->toBigInteger());
}
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall */
/** @phpstan-ignore possiblyImpure.new */
return new Decimal((string) $quotient);
}
public function fromBase(string $value, int $base): IntegerObject
{
try {
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall */
/** @phpstan-ignore possiblyImpure.new */
return new IntegerObject((string) BigInteger::fromBase($value, $base));
} catch (MathException | \InvalidArgumentException $exception) {
throw new InvalidArgumentException(
@@ -125,7 +121,6 @@ final class BrickMathCalculator implements CalculatorInterface
public function toBase(IntegerObject $value, int $base): string
{
try {
/** @phpstan-ignore possiblyImpure.methodCall */
return BigInteger::of($value->toString())->toBase($base);
} catch (MathException | \InvalidArgumentException $exception) {
throw new InvalidArgumentException(