Skip to content

Commit bec7176

Browse files
committed
Update brick/math for static analysis but downgrade in tests for PHP 8.0
1 parent 4618169 commit bec7176

3 files changed

Lines changed: 29 additions & 35 deletions

File tree

.github/workflows/continuous-integration.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ jobs:
194194
coverage: "none"
195195
ini-values: "memory_limit=-1"
196196

197+
- name: "Downgrade brick/math in lock file for PHP 8.0"
198+
run: |
199+
composer update brick/math:"0.8.8"
200+
197201
- name: "Install dependencies (Composer)"
198202
uses: "ramsey/composer-install@v3"
199203
with:

composer.lock

Lines changed: 19 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Math/BrickMathCalculator.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ public function add(NumberInterface $augend, NumberInterface ...$addends): Numbe
4949
$sum = BigInteger::of($augend->toString());
5050

5151
foreach ($addends as $addend) {
52-
/** @phpstan-ignore possiblyImpure.methodCall */
5352
$sum = $sum->plus($addend->toString());
5453
}
5554

56-
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall */
55+
/** @phpstan-ignore possiblyImpure.new */
5756
return new IntegerObject((string) $sum);
5857
}
5958

@@ -62,11 +61,10 @@ public function subtract(NumberInterface $minuend, NumberInterface ...$subtrahen
6261
$difference = BigInteger::of($minuend->toString());
6362

6463
foreach ($subtrahends as $subtrahend) {
65-
/** @phpstan-ignore possiblyImpure.methodCall */
6664
$difference = $difference->minus($subtrahend->toString());
6765
}
6866

69-
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall */
67+
/** @phpstan-ignore possiblyImpure.new */
7068
return new IntegerObject((string) $difference);
7169
}
7270

@@ -75,11 +73,10 @@ public function multiply(NumberInterface $multiplicand, NumberInterface ...$mult
7573
$product = BigInteger::of($multiplicand->toString());
7674

7775
foreach ($multipliers as $multiplier) {
78-
/** @phpstan-ignore possiblyImpure.methodCall */
7976
$product = $product->multipliedBy($multiplier->toString());
8077
}
8178

82-
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall */
79+
/** @phpstan-ignore possiblyImpure.new */
8380
return new IntegerObject((string) $product);
8481
}
8582

@@ -95,23 +92,22 @@ public function divide(
9592
$quotient = BigDecimal::of($dividend->toString());
9693

9794
foreach ($divisors as $divisor) {
98-
/** @phpstan-ignore possiblyImpure.methodCall */
9995
$quotient = $quotient->dividedBy($divisor->toString(), $scale, $brickRounding);
10096
}
10197

10298
if ($scale === 0) {
103-
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall, possiblyImpure.methodCall */
99+
/** @phpstan-ignore possiblyImpure.new */
104100
return new IntegerObject((string) $quotient->toBigInteger());
105101
}
106102

107-
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall */
103+
/** @phpstan-ignore possiblyImpure.new */
108104
return new Decimal((string) $quotient);
109105
}
110106

111107
public function fromBase(string $value, int $base): IntegerObject
112108
{
113109
try {
114-
/** @phpstan-ignore possiblyImpure.new, possiblyImpure.methodCall */
110+
/** @phpstan-ignore possiblyImpure.new */
115111
return new IntegerObject((string) BigInteger::fromBase($value, $base));
116112
} catch (MathException | \InvalidArgumentException $exception) {
117113
throw new InvalidArgumentException(
@@ -125,7 +121,6 @@ public function fromBase(string $value, int $base): IntegerObject
125121
public function toBase(IntegerObject $value, int $base): string
126122
{
127123
try {
128-
/** @phpstan-ignore possiblyImpure.methodCall */
129124
return BigInteger::of($value->toString())->toBase($base);
130125
} catch (MathException | \InvalidArgumentException $exception) {
131126
throw new InvalidArgumentException(

0 commit comments

Comments
 (0)