Skip to content

Commit

Permalink
Fix Psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Dec 16, 2020
1 parent 5125249 commit 4f2b120
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
18 changes: 0 additions & 18 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.2.0@ccf6e2805f4c38655110f425c10ca79511f0bb0e">
<file src="src/Internal/Calculator/BcMathCalculator.php">
<InvalidNullableReturnType occurrences="3">
<code>string</code>
<code>string</code>
<code>string</code>
</InvalidNullableReturnType>
<InvalidReturnStatement occurrences="1">
<code>[$q, $r]</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>array</code>
</InvalidReturnType>
<NullableReturnStatement occurrences="3">
<code>\bcdiv($a, $b, 0)</code>
<code>\bcmod($a, $b)</code>
<code>\bcpowmod($base, $exp, $mod, 0)</code>
</NullableReturnStatement>
</file>
<file src="src/Internal/Calculator/NativeCalculator.php">
<InvalidOperand occurrences="6">
<code>$a</code>
Expand Down
3 changes: 2 additions & 1 deletion src/BigNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,11 @@ private static function floatToString(float $float) : string
* @return static
*
* @psalm-pure
* @psalm-suppress TooManyArguments
* @psalm-suppress UnsafeInstantiation
*/
protected static function create(... $args) : BigNumber
{
/** @psalm-suppress TooManyArguments */
return new static(... $args);
}

Expand Down
12 changes: 12 additions & 0 deletions src/Internal/Calculator/BcMathCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public function mul(string $a, string $b) : string

/**
* {@inheritdoc}
*
* @psalm-suppress InvalidNullableReturnType
* @psalm-suppress NullableReturnStatement
*/
public function divQ(string $a, string $b) : string
{
Expand All @@ -49,6 +52,9 @@ public function divQ(string $a, string $b) : string

/**
* {@inheritdoc}
*
* @psalm-suppress InvalidNullableReturnType
* @psalm-suppress NullableReturnStatement
*/
public function divR(string $a, string $b) : string
{
Expand All @@ -63,6 +69,9 @@ public function divQR(string $a, string $b) : array
$q = \bcdiv($a, $b, 0);
$r = \bcmod($a, $b);

assert($q !== null);
assert($r !== null);

return [$q, $r];
}

Expand All @@ -76,6 +85,9 @@ public function pow(string $a, int $e) : string

/**
* {@inheritdoc}
*
* @psalm-suppress InvalidNullableReturnType
* @psalm-suppress NullableReturnStatement
*/
public function modPow(string $base, string $exp, string $mod) : string
{
Expand Down

0 comments on commit 4f2b120

Please sign in to comment.