@@ -142,13 +142,13 @@ public static function ten() : BigDecimal
142142 /**
143143 * Returns the sum of this number and the given one.
144144 *
145- * The result has a scale of `max($this->scale, $that->scale)`.
145+ * The operand must be convertible to a BigDecimal.
146+ * The result is a BigDecimal with a scale of `max($this->scale, $that->scale)`.
146147 *
147- * @param BigNumber|int|float|string $that The number to add. Must be convertible to a BigDecimal.
148- *
149- * @throws MathException If the number is not valid, or is not convertible to a BigDecimal.
148+ * @throws MathException If the operand is not a valid number or is not convertible to a BigDecimal.
150149 */
151- public function plus (BigNumber |int |float |string $ that ) : BigDecimal
150+ #[Override]
151+ public function plus (BigNumber |int |float |string $ that ) : static
152152 {
153153 $ that = BigDecimal::of ($ that );
154154
@@ -171,13 +171,13 @@ public function plus(BigNumber|int|float|string $that) : BigDecimal
171171 /**
172172 * Returns the difference of this number and the given one.
173173 *
174- * The result has a scale of `max($this->scale, $that->scale)`.
175- *
176- * @param BigNumber|int|float|string $that The number to subtract. Must be convertible to a BigDecimal.
174+ * The operand must be convertible to a BigDecimal.
175+ * The result is a BigDecimal with a scale of `max($this->scale, $that->scale)`.
177176 *
178- * @throws MathException If the number is not valid, or is not convertible to a BigDecimal.
177+ * @throws MathException If the operand is not a valid number or is not convertible to a BigDecimal.
179178 */
180- public function minus (BigNumber |int |float |string $ that ) : BigDecimal
179+ #[Override]
180+ public function minus (BigNumber |int |float |string $ that ) : static
181181 {
182182 $ that = BigDecimal::of ($ that );
183183
@@ -196,13 +196,13 @@ public function minus(BigNumber|int|float|string $that) : BigDecimal
196196 /**
197197 * Returns the product of this number and the given one.
198198 *
199- * The result has a scale of `$this->scale + $that->scale`.
200- *
201- * @param BigNumber|int|float|string $that The multiplier. Must be convertible to a BigDecimal.
199+ * The operand must be convertible to a BigDecimal.
200+ * The result is a BigDecimal with a scale of `$this->scale + $that->scale`.
202201 *
203- * @throws MathException If the multiplier is not a valid number, or is not convertible to a BigDecimal .
202+ * @throws MathException If the operand is not a valid number or is not convertible to a BigInteger .
204203 */
205- public function multipliedBy (BigNumber |int |float |string $ that ) : BigDecimal
204+ #[Override]
205+ public function multipliedBy (BigNumber |int |float |string $ that ) : static
206206 {
207207 $ that = BigDecimal::of ($ that );
208208
@@ -223,14 +223,23 @@ public function multipliedBy(BigNumber|int|float|string $that) : BigDecimal
223223 /**
224224 * Returns the result of the division of this number by the given one, at the given scale.
225225 *
226+ * The operand must be convertible to a BigDecimal.
227+ * The result is a BigDecimal, which by default has the same scale as this number.
228+ * The `$scale` parameter can be used to change the scale of the result.
229+ *
230+ * By default, this method performs an exact division and throws an exception if rounding is necessary.
231+ * The `$roundingMode` parameter can be used to change this behavior.
232+ *
226233 * @param BigNumber|int|float|string $that The divisor.
227234 * @param int|null $scale The desired scale, or null to use the scale of this number.
228- * @param RoundingMode $roundingMode An optional rounding mode, defaults to UNNECESSARY.
235+ * @param RoundingMode $roundingMode An optional rounding mode, defaults to ` UNNECESSARY` .
229236 *
230- * @throws \InvalidArgumentException If the scale or rounding mode is invalid.
231- * @throws MathException If the number is invalid, is zero, or rounding was necessary.
237+ * @throws \InvalidArgumentException If the scale is negative.
238+ * @throws MathException If the operand is not a valid number, is not convertible to a BigDecimal, is
239+ * zero, or rounding is necessary but `RoundingMode::UNNECESSARY` was provided.
232240 */
233- public function dividedBy (BigNumber |int |float |string $ that , ?int $ scale = null , RoundingMode $ roundingMode = RoundingMode::UNNECESSARY ) : BigDecimal
241+ #[Override]
242+ public function dividedBy (BigNumber |int |float |string $ that , ?int $ scale = null , RoundingMode $ roundingMode = RoundingMode::UNNECESSARY ) : static
234243 {
235244 $ that = BigDecimal::of ($ that );
236245
0 commit comments