diff options
-rw-r--r-- | ext/bcmath/bcmath.c | 70 | ||||
-rw-r--r-- | ext/bcmath/bcmath.stub.php | 22 | ||||
-rw-r--r-- | ext/bcmath/bcmath_arginfo.h | 47 |
3 files changed, 74 insertions, 65 deletions
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index f1b933ad72..7f26576ddf 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -25,6 +25,7 @@ #if HAVE_BCMATH #include "php_ini.h" +#include "bcmath_arginfo.h" #include "ext/standard/info.h" #include "php_bcmath.h" #include "libbcmath/src/bcmath.h" @@ -33,67 +34,6 @@ ZEND_DECLARE_MODULE_GLOBALS(bcmath) static PHP_GINIT_FUNCTION(bcmath); static PHP_GSHUTDOWN_FUNCTION(bcmath); -/* {{{ arginfo */ -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcadd, 0, 2, IS_STRING, 0) - ZEND_ARG_INFO(0, left_operand) - ZEND_ARG_INFO(0, right_operand) - ZEND_ARG_INFO(0, scale) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcsub, 0, 2, IS_STRING, 0) - ZEND_ARG_INFO(0, left_operand) - ZEND_ARG_INFO(0, right_operand) - ZEND_ARG_INFO(0, scale) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcmul, 0, 2, IS_STRING, 0) - ZEND_ARG_INFO(0, left_operand) - ZEND_ARG_INFO(0, right_operand) - ZEND_ARG_INFO(0, scale) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcdiv, 0, 2, IS_STRING, 1) - ZEND_ARG_INFO(0, left_operand) - ZEND_ARG_INFO(0, right_operand) - ZEND_ARG_INFO(0, scale) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcmod, 0, 2, IS_STRING, 1) - ZEND_ARG_INFO(0, left_operand) - ZEND_ARG_INFO(0, right_operand) - ZEND_ARG_INFO(0, scale) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_bcpowmod, 0, 0, 3) - ZEND_ARG_INFO(0, x) - ZEND_ARG_INFO(0, y) - ZEND_ARG_INFO(0, mod) - ZEND_ARG_INFO(0, scale) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcpow, 0, 2, IS_STRING, 0) - ZEND_ARG_INFO(0, x) - ZEND_ARG_INFO(0, y) - ZEND_ARG_INFO(0, scale) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcsqrt, 0, 1, IS_STRING, 1) - ZEND_ARG_INFO(0, operand) - ZEND_ARG_INFO(0, scale) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bccomp, 0, 2, IS_LONG, 0) - ZEND_ARG_INFO(0, left_operand) - ZEND_ARG_INFO(0, right_operand) - ZEND_ARG_INFO(0, scale) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcscale, 0, 0, IS_LONG, 0) - ZEND_ARG_INFO(0, scale) -ZEND_END_ARG_INFO() - -/* }}} */ - static const zend_function_entry bcmath_functions[] = { PHP_FE(bcadd, arginfo_bcadd) PHP_FE(bcsub, arginfo_bcsub) @@ -400,10 +340,10 @@ PHP_FUNCTION(bcmod) /* }}} */ /* {{{ proto string bcpowmod(string x, string y, string mod [, int scale]) - Returns the value of an arbitrary precision number raised to the power of another reduced by a modulous */ + Returns the value of an arbitrary precision number raised to the power of another reduced by a modulus */ PHP_FUNCTION(bcpowmod) { - zend_string *left, *right, *modulous; + zend_string *left, *right, *modulus; bc_num first, second, mod, result; zend_long scale = BCG(bc_precision); int scale_int; @@ -411,7 +351,7 @@ PHP_FUNCTION(bcpowmod) ZEND_PARSE_PARAMETERS_START(3, 4) Z_PARAM_STR(left) Z_PARAM_STR(right) - Z_PARAM_STR(modulous) + Z_PARAM_STR(modulus) Z_PARAM_OPTIONAL Z_PARAM_LONG(scale) ZEND_PARSE_PARAMETERS_END(); @@ -422,7 +362,7 @@ PHP_FUNCTION(bcpowmod) bc_init_num(&result); php_str2num(&first, ZSTR_VAL(left)); php_str2num(&second, ZSTR_VAL(right)); - php_str2num(&mod, ZSTR_VAL(modulous)); + php_str2num(&mod, ZSTR_VAL(modulus)); scale_int = (int) ((int)scale < 0 ? 0 : scale); diff --git a/ext/bcmath/bcmath.stub.php b/ext/bcmath/bcmath.stub.php new file mode 100644 index 0000000000..b5d1816acc --- /dev/null +++ b/ext/bcmath/bcmath.stub.php @@ -0,0 +1,22 @@ +<?php + +function bcadd(string $left_operand, string $right_operand, int $scale = UNKNOWN) : string {} + +function bcsub(string $left_operand, string $right_operand, int $scale = UNKNOWN) : string {} + +function bcmul(string $left_operand, string $right_operand, int $scale = UNKNOWN) : string {} + +function bcdiv(string $dividend, string $divisor, int $scale = UNKNOWN) : ?string {} + +function bcmod(string $dividend, string $divisor, int $scale = UNKNOWN) : ?string {} + +/** @return string|false */ +function bcpowmod(string $base, string $exponent, string $modulus, int $scale = UNKNOWN) {} + +function bcpow(string $base, string $exponent, int $scale = UNKNOWN) : string {} + +function bcsqrt(string $operand, int $scale = UNKNOWN) : ?string {} + +function bccomp(string $left_operand, string $right_operand, int $scale = UNKNOWN) : int {} + +function bcscale(int $scale = UNKNOWN) : int {} diff --git a/ext/bcmath/bcmath_arginfo.h b/ext/bcmath/bcmath_arginfo.h new file mode 100644 index 0000000000..6c0b1061f2 --- /dev/null +++ b/ext/bcmath/bcmath_arginfo.h @@ -0,0 +1,47 @@ +/* This is a generated file, edit the .stub.php file instead. */ + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcadd, 0, 2, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, left_operand, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, right_operand, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, scale, IS_LONG, 0) +ZEND_END_ARG_INFO() + +#define arginfo_bcsub arginfo_bcadd + +#define arginfo_bcmul arginfo_bcadd + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcdiv, 0, 2, IS_STRING, 1) + ZEND_ARG_TYPE_INFO(0, dividend, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, divisor, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, scale, IS_LONG, 0) +ZEND_END_ARG_INFO() + +#define arginfo_bcmod arginfo_bcdiv + +ZEND_BEGIN_ARG_INFO_EX(arginfo_bcpowmod, 0, 0, 3) + ZEND_ARG_TYPE_INFO(0, base, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, exponent, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, modulus, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, scale, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcpow, 0, 2, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, base, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, exponent, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, scale, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcsqrt, 0, 1, IS_STRING, 1) + ZEND_ARG_TYPE_INFO(0, operand, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, scale, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bccomp, 0, 2, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, left_operand, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, right_operand, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, scale, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcscale, 0, 0, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, scale, IS_LONG, 0) +ZEND_END_ARG_INFO() |