1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Files
archived-php-src/ext/bcmath/bcmath.stub.php
Saki Takamachi fad899e566 [RFC] Support object types in BCMath (#13741)
Added BcMath\Number class. It is an immutable object, has methods that are
equivalent to existing BCMath calculation functions, and can also be calculated
using operators.

The existing BCMath function returned a string for each calculation, but this
class returns an object.

RFC: https://wiki.php.net/rfc/support_object_type_in_bcmath,
https://wiki.php.net/rfc/fix_up_bcmath_number_class

---------

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2024-09-04 11:12:51 +09:00

88 lines
2.6 KiB
PHP

<?php
/** @generate-class-entries */
namespace
{
/** @refcount 1 */
function bcadd(string $num1, string $num2, ?int $scale = null): string {}
/** @refcount 1 */
function bcsub(string $num1, string $num2, ?int $scale = null): string {}
/** @refcount 1 */
function bcmul(string $num1, string $num2, ?int $scale = null): string {}
/** @refcount 1 */
function bcdiv(string $num1, string $num2, ?int $scale = null): string {}
/** @refcount 1 */
function bcmod(string $num1, string $num2, ?int $scale = null): string {}
/** @refcount 1 */
function bcpowmod(string $num, string $exponent, string $modulus, ?int $scale = null): string {}
/** @refcount 1 */
function bcpow(string $num, string $exponent, ?int $scale = null): string {}
/** @refcount 1 */
function bcsqrt(string $num, ?int $scale = null): string {}
function bccomp(string $num1, string $num2, ?int $scale = null): int {}
function bcscale(?int $scale = null): int {}
/** @refcount 1 */
function bcfloor(string $num): string {}
/** @refcount 1 */
function bcceil(string $num): string {}
/** @refcount 1 */
function bcround(string $num, int $precision = 0, RoundingMode $mode = RoundingMode::HalfAwayFromZero): string {}
}
namespace BcMath
{
/** @strict-properties */
final readonly class Number implements \Stringable
{
/** @virtual */
public string $value;
/** @virtual */
public int $scale;
public function __construct(string|int $num) {}
public function add(Number|string|int $num, ?int $scale = null): Number {}
public function sub(Number|string|int $num, ?int $scale = null): Number {}
public function mul(Number|string|int $num, ?int $scale = null): Number {}
public function div(Number|string|int $num, ?int $scale = null): Number {}
public function mod(Number|string|int $num, ?int $scale = null): Number {}
public function powmod(Number|string|int $exponent, Number|string|int $modulus, ?int $scale = null): Number {}
public function pow(Number|string|int $exponent, ?int $scale = null): Number {}
public function sqrt(?int $scale = null): Number {}
public function floor(): Number {}
public function ceil(): Number {}
public function round(int $precision = 0, \RoundingMode $mode = \RoundingMode::HalfAwayFromZero): Number {}
public function compare(Number|string|int $num, ?int $scale = null): int {}
public function __toString(): string {}
public function __serialize(): array {}
public function __unserialize(array $data): void {}
}
}