@@ -78,8 +78,8 @@ protected function __construct(string $value)
7878 *
7979 * For bases greater than 36, and/or custom alphabets, use the fromArbitraryBase() method.
8080 *
81- * @param string $number The number to convert, in the given base.
82- * @param int $base The base of the number, between 2 and 36.
81+ * @param string $number The number to convert, in the given base.
82+ * @param int<2, 36> $base The base of the number, between 2 and 36.
8383 *
8484 * @throws NumberFormatException If the number is empty, or contains invalid chars for the given base.
8585 * @throws InvalidArgumentException If the base is out of range.
@@ -88,7 +88,7 @@ protected function __construct(string $value)
8888 */
8989 public static function fromBase (string $ number , int $ base ): BigInteger
9090 {
91- if ($ base < 2 || $ base > 36 ) {
91+ if ($ base < 2 || $ base > 36 ) { // @phpstan-ignore smaller.alwaysFalse, greater.alwaysFalse, booleanOr.alwaysFalse
9292 throw InvalidArgumentException::baseOutOfRange ($ base );
9393 }
9494
@@ -232,7 +232,7 @@ public static function fromBytes(string $value, bool $signed = true): BigInteger
232232 *
233233 * Using the default random bytes generator, this method is suitable for cryptographic use.
234234 *
235- * @param int $bitCount The number of bits.
235+ * @param non-negative- int $bitCount The number of bits.
236236 * @param (callable(int): string)|null $randomBytesGenerator A function that accepts a number of bytes, and returns
237237 * a string of random bytes of the given length. Defaults
238238 * to the `random_bytes()` function.
@@ -242,7 +242,7 @@ public static function fromBytes(string $value, bool $signed = true): BigInteger
242242 */
243243 public static function randomBits (int $ bitCount , ?callable $ randomBytesGenerator = null ): BigInteger
244244 {
245- if ($ bitCount < 0 ) {
245+ if ($ bitCount < 0 ) { // @phpstan-ignore smaller.alwaysFalse
246246 throw InvalidArgumentException::negativeBitCount ();
247247 }
248248
@@ -527,6 +527,8 @@ public function dividedBy(BigNumber|int|string $that, RoundingMode $roundingMode
527527 /**
528528 * Returns this number exponentiated to the given value.
529529 *
530+ * @param non-negative-int $exponent
531+ *
530532 * @throws InvalidArgumentException If the exponent is negative.
531533 *
532534 * @pure
@@ -541,7 +543,7 @@ public function power(int $exponent): BigInteger
541543 return $ this ;
542544 }
543545
544- if ($ exponent < 0 ) {
546+ if ($ exponent < 0 ) { // @phpstan-ignore smaller.alwaysFalse
545547 throw InvalidArgumentException::negativeExponent ();
546548 }
547549
@@ -1004,6 +1006,8 @@ public function shiftedRight(int $bits): BigInteger
10041006 * For positive BigIntegers, this is equivalent to the number of bits in the ordinary binary representation.
10051007 * Computes (ceil(log2(this < 0 ? -this : this+1))).
10061008 *
1009+ * @return non-negative-int
1010+ *
10071011 * @pure
10081012 */
10091013 public function getBitLength (): int
@@ -1047,15 +1051,15 @@ public function getLowestSetBit(): int
10471051 *
10481052 * Computes ((this & (1<<bitIndex)) != 0).
10491053 *
1050- * @param int $bitIndex The bit to test, 0-based.
1054+ * @param non-negative- int $bitIndex The bit to test, 0-based.
10511055 *
10521056 * @throws InvalidArgumentException If the bit to test is negative.
10531057 *
10541058 * @pure
10551059 */
10561060 public function isBitSet (int $ bitIndex ): bool
10571061 {
1058- if ($ bitIndex < 0 ) {
1062+ if ($ bitIndex < 0 ) { // @phpstan-ignore smaller.alwaysFalse
10591063 throw InvalidArgumentException::negativeBitIndex ();
10601064 }
10611065
@@ -1147,6 +1151,8 @@ public function toFloat(): float
11471151 *
11481152 * The output will always be lowercase for bases greater than 10.
11491153 *
1154+ * @param int<2, 36> $base
1155+ *
11501156 * @throws InvalidArgumentException If the base is out of range.
11511157 *
11521158 * @pure
@@ -1157,7 +1163,7 @@ public function toBase(int $base): string
11571163 return $ this ->value ;
11581164 }
11591165
1160- if ($ base < 2 || $ base > 36 ) {
1166+ if ($ base < 2 || $ base > 36 ) { // @phpstan-ignore smaller.alwaysFalse, greater.alwaysFalse, booleanOr.alwaysFalse
11611167 throw InvalidArgumentException::baseOutOfRange ($ base );
11621168 }
11631169
0 commit comments