diff --git a/decimal/decimal.php b/decimal/decimal.php index 04767b86..0fa514a8 100644 --- a/decimal/decimal.php +++ b/decimal/decimal.php @@ -1,440 +1,467 @@ ` operator. + * + * @param mixed $other + * + * @return int 0 if this decimal is considered is equal to $other, + * -1 if this decimal should be placed before $other, + * 1 if this decimal should be placed after $other. + */ + public function compareTo($other): int {} - /** - * @return Decimal - */ - public function copy(): Decimal { } + /** + * String representation. + * + * This method is equivalent to a cast to string, as well as `toString`. + * + * @return string the value of this decimal represented exactly, in either + * fixed or scientific form, depending on the value. + */ + public function __toString(): string {} - /** - * This method is equivalent to the == operator. - * - * @param mixed $value - * - * @return bool TRUE if this decimal is considered equal to the given value. - * - * @link https://php-decimal.io/#equals - */ - public function equals($value): bool { } - - /** - * This method is equivalent to the <=> operator. - * - * Returns 0 if this decimal is considered equal to $other, - * -1 if this decimal should be placed before $other, - * 1 if this decimal should be placed after $other. - * - * @param $value - * - * @return int - * - * @link https://php-decimal.io/#compareTo - */ - public function compareTo($value): int { } - - /** - * Returns TRUE if the value is between the two operands - * - * @param Decimam|string|int $value - * @param Decimam|string|int $leftOp - * @param Decimam|string|int $rightOp - * - * @return bool - */ - public function between($value, $leftOp, $rightOp): bool { } - - /** - * Returns the sum of all given values - * - * The precision of the result will be the max of all precisions that were encountered during the calculation. - * The given precision should therefore be considered the minimum precision of the result. - * This method is equivalent to adding each value individually - * - * @param array|Traversable $values - * - * @return Decimal - * - * @link https://php-decimal.io/#sum - */ - public function sum(array $values): Decimal { } - - /** - * Returns the average of all given values - * - * The precision of the result will be the max of all precisions that were encountered during the calculation. - * The given precision should therefore be considered the minimum precision of the result. - * This method is equivalent to adding each value individually, then dividing by the number of values - * @param array $values - * - * @return Decimal - * - * @link https://php-decimal.io/#avg - */ - public function avg(array $values): Decimal { } - } + /** + * JSON + * + * This method is only here to honour the interface, and is equivalent to + * `toString`. JSON does not have a decimal type so all decimals are encoded + * as strings in the same format as `toString`. + * + * @return string + */ + public function jsonSerialize() {} }