diff options
36 files changed, 275 insertions, 332 deletions
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 5cb4027d1e..8df61de51b 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -589,11 +589,8 @@ static int convert_to_gmp(mpz_t gmpnumber, zval *val, zend_long base, uint32_t a { switch (Z_TYPE_P(val)) { case IS_LONG: - case IS_FALSE: - case IS_TRUE: { - mpz_set_si(gmpnumber, zval_get_long(val)); + mpz_set_si(gmpnumber, Z_LVAL_P(val)); return SUCCESS; - } case IS_STRING: { char *numstr = Z_STRVAL_P(val); zend_bool skip_lead = 0; @@ -623,14 +620,16 @@ static int convert_to_gmp(mpz_t gmpnumber, zval *val, zend_long base, uint32_t a return SUCCESS; } - default: - /* if unserializing */ - if (arg_pos == 0) { - php_error_docref(NULL, E_WARNING, "Cannot convert variable of type %s to GMP", zend_zval_type_name(val)); + default: { + zend_long lval; + if (!zend_parse_arg_long_slow(val, &lval)) { + zend_argument_type_error(arg_pos, "must be of type GMP|string|int, %s given", zend_zval_type_name(val)); return FAILURE; } - zend_argument_type_error(arg_pos, "must be of type GMP|string|int|bool, %s given", zend_zval_type_name(val)); - return FAILURE; + + mpz_set_si(gmpnumber, lval); + return SUCCESS; + } } } /* }}} */ @@ -992,16 +991,16 @@ ZEND_FUNCTION(gmp_export) ZEND_FUNCTION(gmp_intval) { zval *gmpnumber_arg; + mpz_ptr gmpnum; + gmp_temp_t temp_a; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &gmpnumber_arg) == FAILURE){ RETURN_THROWS(); } - if (IS_GMP(gmpnumber_arg)) { - RETVAL_LONG(mpz_get_si(GET_GMP_FROM_ZVAL(gmpnumber_arg))); - } else { - RETVAL_LONG(zval_get_long(gmpnumber_arg)); - } + FETCH_GMP_ZVAL(gmpnum, gmpnumber_arg, temp_a, 1); + RETVAL_LONG(mpz_get_si(gmpnum)); + FREE_GMP_TEMP(temp_a); } /* }}} */ diff --git a/ext/gmp/gmp.stub.php b/ext/gmp/gmp.stub.php index 6d4390ab41..8f2c6ed944 100644 --- a/ext/gmp/gmp.stub.php +++ b/ext/gmp/gmp.stub.php @@ -6,222 +6,105 @@ class GMP { } -/** @param int|bool|string $number */ -function gmp_init($number, int $base = 0): GMP {} +function gmp_init(int|string $number, int $base = 0): GMP {} function gmp_import(string $data, int $word_size = 1, int $options = GMP_MSW_FIRST | GMP_NATIVE_ENDIAN): GMP {} -/** @param GMP|int|bool|string $gmpnumber */ -function gmp_export($gmpnumber, int $word_size = 1, int $options = GMP_MSW_FIRST | GMP_NATIVE_ENDIAN): string {} - -/** @param GMP|int|bool|string $gmpnumber */ -function gmp_intval($gmpnumber): int {} - -/** @param GMP|int|bool|string $gmpnumber */ -function gmp_strval($gmpnumber, int $base = 10): string {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_add($a, $b): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_sub($a, $b): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_mul($a, $b): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_div_qr($a, $b, int $round = GMP_ROUND_ZERO): array {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_div_q($a, $b, int $round = GMP_ROUND_ZERO): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_div_r($a, $b, int $round = GMP_ROUND_ZERO): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - * @alias gmp_div_q - */ -function gmp_div($a, $b, int $round = GMP_ROUND_ZERO): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_mod($a, $b): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_divexact($a, $b): GMP {} - -/** @param GMP|int|bool|string $a */ -function gmp_neg($a): GMP {} - -/** @param GMP|int|bool|string $a */ -function gmp_abs($a): GMP {} - -/** @param GMP|int|bool|string $a */ -function gmp_fact($a): GMP {} - -/** @param GMP|int|bool|string $a */ -function gmp_sqrt($a): GMP {} - -/** @param GMP|int|bool|string $a */ -function gmp_sqrtrem($a): array {} - -/** @param GMP|int|bool|string $a */ -function gmp_root($a, int $nth): GMP {} - -/** @param GMP|int|bool|string $a */ -function gmp_rootrem($a, int $nth): array {} - -/** @param GMP|int|bool|string $base */ -function gmp_pow($base, int $exp): GMP {} - -/** - * @param GMP|int|bool|string $base - * @param GMP|int|bool|string $exp - * @param GMP|int|bool|string $mod - */ -function gmp_powm($base, $exp, $mod): GMP {} - -/** @param GMP|int|bool|string $a */ -function gmp_perfect_square($a): bool {} - -/** @param GMP|int|bool|string $a */ -function gmp_perfect_power($a): bool {} - -/** @param GMP|int|bool|string $a */ -function gmp_prob_prime($a, int $reps = 10): int {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_gcd($a, $b): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_gcdext($a, $b): array {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_lcm($a, $b): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_invert($a, $b): GMP|false {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_jacobi($a, $b): int {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_legendre($a, $b): int {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_kronecker($a, $b): int {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_cmp($a, $b): int {} - -/** @param GMP|int|bool|string $a */ -function gmp_sign($a): int {} - -/** @param GMP|int|bool|string $seed */ -function gmp_random_seed($seed): void {} +function gmp_export(GMP|int|string $gmpnumber, int $word_size = 1, int $options = GMP_MSW_FIRST | GMP_NATIVE_ENDIAN): string {} + +function gmp_intval(GMP|int|string $gmpnumber): int {} + +function gmp_strval(GMP|int|string $gmpnumber, int $base = 10): string {} + +function gmp_add(GMP|int|string $a, GMP|int|string $b): GMP {} + +function gmp_sub(GMP|int|string $a, GMP|int|string $b): GMP {} + +function gmp_mul(GMP|int|string $a, GMP|int|string $b): GMP {} + +function gmp_div_qr(GMP|int|string $a, GMP|int|string $b, int $round = GMP_ROUND_ZERO): array {} + +function gmp_div_q(GMP|int|string $a, GMP|int|string $b, int $round = GMP_ROUND_ZERO): GMP {} + +function gmp_div_r(GMP|int|string $a, GMP|int|string $b, int $round = GMP_ROUND_ZERO): GMP {} + +/** @alias gmp_div_q */ +function gmp_div(GMP|int|string $a, GMP|int|string $b, int $round = GMP_ROUND_ZERO): GMP {} + +function gmp_mod(GMP|int|string $a, GMP|int|string $b): GMP {} + +function gmp_divexact(GMP|int|string $a, GMP|int|string $b): GMP {} + +function gmp_neg(GMP|int|string $a): GMP {} + +function gmp_abs(GMP|int|string $a): GMP {} + +function gmp_fact(GMP|int|string $a): GMP {} + +function gmp_sqrt(GMP|int|string $a): GMP {} + +function gmp_sqrtrem(GMP|int|string $a): array {} + +function gmp_root(GMP|int|string $a, int $nth): GMP {} + +function gmp_rootrem(GMP|int|string $a, int $nth): array {} + +function gmp_pow(GMP|int|string $base, int $exp): GMP {} + +function gmp_powm(GMP|int|string $base, GMP|int|string $exp, GMP|int|string $mod): GMP {} + +function gmp_perfect_square(GMP|int|string $a): bool {} + +function gmp_perfect_power(GMP|int|string $a): bool {} + +function gmp_prob_prime(GMP|int|string $a, int $reps = 10): int {} + +function gmp_gcd(GMP|int|string $a, GMP|int|string $b): GMP {} + +function gmp_gcdext(GMP|int|string $a, GMP|int|string $b): array {} + +function gmp_lcm(GMP|int|string $a, GMP|int|string $b): GMP {} + +function gmp_invert(GMP|int|string $a, GMP|int|string $b): GMP|false {} + +function gmp_jacobi(GMP|int|string $a, GMP|int|string $b): int {} + +function gmp_legendre(GMP|int|string $a, GMP|int|string $b): int {} + +function gmp_kronecker(GMP|int|string $a, GMP|int|string $b): int {} + +function gmp_cmp(GMP|int|string $a, GMP|int|string $b): int {} + +function gmp_sign(GMP|int|string $a): int {} + +function gmp_random_seed(GMP|int|string $seed): void {} function gmp_random_bits(int $bits): GMP {} -/** - * @param GMP|int|bool|string $min - * @param GMP|int|bool|string $max - **/ -function gmp_random_range($min, $max): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_and($a, $b): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_or($a, $b): GMP {} - -/** @param GMP|int|bool|string $a */ -function gmp_com($a): GMP {} - -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_xor($a, $b): GMP {} +function gmp_random_range(GMP|int|string $min, GMP|int|string $max): GMP {} + +function gmp_and(GMP|int|string $a, GMP|int|string $b): GMP {} + +function gmp_or(GMP|int|string $a, GMP|int|string $b): GMP {} + +function gmp_com(GMP|int|string $a): GMP {} + +function gmp_xor(GMP|int|string $a, GMP|int|string $b): GMP {} function gmp_setbit(GMP $a, int $index, bool $set_clear = true): void {} function gmp_clrbit(GMP $a, int $index): void {} -/** @param GMP|int|bool|string $a */ -function gmp_testbit($a, int $index): bool {} +function gmp_testbit(GMP|int|string $a, int $index): bool {} -/** @param GMP|int|bool|string $a */ -function gmp_scan0($a, int $start): int {} +function gmp_scan0(GMP|int|string $a, int $start): int {} -/** @param GMP|int|bool|string $a */ -function gmp_scan1($a, int $start): int {} +function gmp_scan1(GMP|int|string $a, int $start): int {} -/** @param GMP|int|bool|string $a */ -function gmp_popcount($a): int {} +function gmp_popcount(GMP|int|string $a): int {} -/** - * @param GMP|int|bool|string $a - * @param GMP|int|bool|string $b - */ -function gmp_hamdist($a, $b): int {} +function gmp_hamdist(GMP|int|string $a, GMP|int|string $b): int {} -/** @param GMP|int|bool|string $a */ -function gmp_nextprime($a): GMP {} +function gmp_nextprime(GMP|int|string $a): GMP {} -/** @param GMP|int|bool|string $a */ -function gmp_binomial($a, int $b): GMP {} +function gmp_binomial(GMP|int|string $a, int $b): GMP {} diff --git a/ext/gmp/gmp_arginfo.h b/ext/gmp/gmp_arginfo.h index e0fd4f8318..9f4a44f6d7 100644 --- a/ext/gmp/gmp_arginfo.h +++ b/ext/gmp/gmp_arginfo.h @@ -1,8 +1,8 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: b2bbdaeb1b396bd20eb59eefc92116be80ddb63b */ + * Stub hash: fe4ff47c3359705bf2b1a64a882659fabd370bab */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_init, 0, 1, GMP, 0) - ZEND_ARG_INFO(0, number) + ZEND_ARG_TYPE_MASK(0, number, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, base, IS_LONG, 0, "0") ZEND_END_ARG_INFO() @@ -13,23 +13,23 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_import, 0, 1, GMP, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_export, 0, 1, IS_STRING, 0) - ZEND_ARG_INFO(0, gmpnumber) + ZEND_ARG_OBJ_TYPE_MASK(0, gmpnumber, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, word_size, IS_LONG, 0, "1") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "GMP_MSW_FIRST | GMP_NATIVE_ENDIAN") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_intval, 0, 1, IS_LONG, 0) - ZEND_ARG_INFO(0, gmpnumber) + ZEND_ARG_OBJ_TYPE_MASK(0, gmpnumber, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_strval, 0, 1, IS_STRING, 0) - ZEND_ARG_INFO(0, gmpnumber) + ZEND_ARG_OBJ_TYPE_MASK(0, gmpnumber, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, base, IS_LONG, 0, "10") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_add, 0, 2, GMP, 0) - ZEND_ARG_INFO(0, a) - ZEND_ARG_INFO(0, b) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, b, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() #define arginfo_gmp_sub arginfo_gmp_add @@ -37,14 +37,14 @@ ZEND_END_ARG_INFO() #define arginfo_gmp_mul arginfo_gmp_add ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_div_qr, 0, 2, IS_ARRAY, 0) - ZEND_ARG_INFO(0, a) - ZEND_ARG_INFO(0, b) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, b, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, round, IS_LONG, 0, "GMP_ROUND_ZERO") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_div_q, 0, 2, GMP, 0) - ZEND_ARG_INFO(0, a) - ZEND_ARG_INFO(0, b) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, b, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, round, IS_LONG, 0, "GMP_ROUND_ZERO") ZEND_END_ARG_INFO() @@ -57,7 +57,7 @@ ZEND_END_ARG_INFO() #define arginfo_gmp_divexact arginfo_gmp_add ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_neg, 0, 1, GMP, 0) - ZEND_ARG_INFO(0, a) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() #define arginfo_gmp_abs arginfo_gmp_neg @@ -67,58 +67,58 @@ ZEND_END_ARG_INFO() #define arginfo_gmp_sqrt arginfo_gmp_neg ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_sqrtrem, 0, 1, IS_ARRAY, 0) - ZEND_ARG_INFO(0, a) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_root, 0, 2, GMP, 0) - ZEND_ARG_INFO(0, a) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO(0, nth, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_rootrem, 0, 2, IS_ARRAY, 0) - ZEND_ARG_INFO(0, a) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO(0, nth, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_pow, 0, 2, GMP, 0) - ZEND_ARG_INFO(0, base) + ZEND_ARG_OBJ_TYPE_MASK(0, base, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO(0, exp, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_powm, 0, 3, GMP, 0) - ZEND_ARG_INFO(0, base) - ZEND_ARG_INFO(0, exp) - ZEND_ARG_INFO(0, mod) + ZEND_ARG_OBJ_TYPE_MASK(0, base, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, exp, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, mod, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_perfect_square, 0, 1, _IS_BOOL, 0) - ZEND_ARG_INFO(0, a) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() #define arginfo_gmp_perfect_power arginfo_gmp_perfect_square ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_prob_prime, 0, 1, IS_LONG, 0) - ZEND_ARG_INFO(0, a) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, reps, IS_LONG, 0, "10") ZEND_END_ARG_INFO() #define arginfo_gmp_gcd arginfo_gmp_add ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_gcdext, 0, 2, IS_ARRAY, 0) - ZEND_ARG_INFO(0, a) - ZEND_ARG_INFO(0, b) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, b, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() #define arginfo_gmp_lcm arginfo_gmp_add ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_gmp_invert, 0, 2, GMP, MAY_BE_FALSE) - ZEND_ARG_INFO(0, a) - ZEND_ARG_INFO(0, b) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, b, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_jacobi, 0, 2, IS_LONG, 0) - ZEND_ARG_INFO(0, a) - ZEND_ARG_INFO(0, b) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, b, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() #define arginfo_gmp_legendre arginfo_gmp_jacobi @@ -128,11 +128,11 @@ ZEND_END_ARG_INFO() #define arginfo_gmp_cmp arginfo_gmp_jacobi ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_sign, 0, 1, IS_LONG, 0) - ZEND_ARG_INFO(0, a) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_random_seed, 0, 1, IS_VOID, 0) - ZEND_ARG_INFO(0, seed) + ZEND_ARG_OBJ_TYPE_MASK(0, seed, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_random_bits, 0, 1, GMP, 0) @@ -140,8 +140,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_random_bits, 0, 1, GMP, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_random_range, 0, 2, GMP, 0) - ZEND_ARG_INFO(0, min) - ZEND_ARG_INFO(0, max) + ZEND_ARG_OBJ_TYPE_MASK(0, min, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) + ZEND_ARG_OBJ_TYPE_MASK(0, max, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() #define arginfo_gmp_and arginfo_gmp_add @@ -164,12 +164,12 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_clrbit, 0, 2, IS_VOID, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_testbit, 0, 2, _IS_BOOL, 0) - ZEND_ARG_INFO(0, a) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gmp_scan0, 0, 2, IS_LONG, 0) - ZEND_ARG_INFO(0, a) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0) ZEND_END_ARG_INFO() @@ -182,7 +182,7 @@ ZEND_END_ARG_INFO() #define arginfo_gmp_nextprime arginfo_gmp_neg ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gmp_binomial, 0, 2, GMP, 0) - ZEND_ARG_INFO(0, a) + ZEND_ARG_OBJ_TYPE_MASK(0, a, GMP, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_END_ARG_INFO() diff --git a/ext/gmp/tests/gmp_abs.phpt b/ext/gmp/tests/gmp_abs.phpt index 3b64004c89..0fb8ba5f1a 100644 --- a/ext/gmp/tests/gmp_abs.phpt +++ b/ext/gmp/tests/gmp_abs.phpt @@ -47,11 +47,11 @@ echo "Done\n"; gmp_abs(): Argument #1 ($a) is not an integer string string(1) "0" string(1) "0" -gmp_abs(): Argument #1 ($a) must be of type GMP|string|int|bool, float given +gmp_abs(): Argument #1 ($a) must be of type GMP|string|int, float given string(21) "111111111111111111111" string(21) "111111111111111111111" string(1) "0" gmp_abs(): Argument #1 ($a) is not an integer string gmp_abs(): Argument #1 ($a) is not an integer string -gmp_abs(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_abs(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_and.phpt b/ext/gmp/tests/gmp_and.phpt index 90387e5f64..26ed3dda37 100644 --- a/ext/gmp/tests/gmp_and.phpt +++ b/ext/gmp/tests/gmp_and.phpt @@ -50,7 +50,7 @@ string(4) "4544" gmp_and(): Argument #1 ($a) is not an integer string string(4) "1536" string(15) "424703623692768" -gmp_and(): Argument #1 ($a) must be of type GMP|string|int|bool, array given -gmp_and(): Argument #2 ($b) must be of type GMP|string|int|bool, array given -gmp_and(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_and(): Argument #1 ($a) must be of type GMP|string|int, array given +gmp_and(): Argument #2 ($b) must be of type GMP|string|int, array given +gmp_and(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_cmp.phpt b/ext/gmp/tests/gmp_cmp.phpt index 98e3c9ec3e..35c2796ffa 100644 --- a/ext/gmp/tests/gmp_cmp.phpt +++ b/ext/gmp/tests/gmp_cmp.phpt @@ -34,5 +34,5 @@ int(1) int(-1) bool(true) int(0) -gmp_cmp(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_cmp(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_com.phpt b/ext/gmp/tests/gmp_com.phpt index 7f653f7ad3..71f9f39e96 100644 --- a/ext/gmp/tests/gmp_com.phpt +++ b/ext/gmp/tests/gmp_com.phpt @@ -40,5 +40,5 @@ string(7) "-874654" string(4) "9875" string(9) "-98765468" string(12) "-98765463338" -gmp_com(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_com(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_div_q.phpt b/ext/gmp/tests/gmp_div_q.phpt index c86eb952fe..08d82c6132 100644 --- a/ext/gmp/tests/gmp_div_q.phpt +++ b/ext/gmp/tests/gmp_div_q.phpt @@ -76,6 +76,6 @@ object(GMP)#1 (1) { ["num"]=> string(4) "9131" } -gmp_div_q(): Argument #1 ($a) must be of type GMP|string|int|bool, resource given -gmp_div_q(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_div_q(): Argument #1 ($a) must be of type GMP|string|int, resource given +gmp_div_q(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_div_qr.phpt b/ext/gmp/tests/gmp_div_qr.phpt index 7af729804e..03c5facac2 100644 --- a/ext/gmp/tests/gmp_div_qr.phpt +++ b/ext/gmp/tests/gmp_div_qr.phpt @@ -159,6 +159,6 @@ array(2) { string(2) "10" } } -gmp_div_qr(): Argument #1 ($a) must be of type GMP|string|int|bool, resource given -gmp_div_qr(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_div_qr(): Argument #1 ($a) must be of type GMP|string|int, resource given +gmp_div_qr(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_div_r.phpt b/ext/gmp/tests/gmp_div_r.phpt index 1cf1e66252..eab9286fe7 100644 --- a/ext/gmp/tests/gmp_div_r.phpt +++ b/ext/gmp/tests/gmp_div_r.phpt @@ -76,6 +76,6 @@ object(GMP)#3 (1) { ["num"]=> string(2) "10" } -gmp_div_r(): Argument #1 ($a) must be of type GMP|string|int|bool, resource given -gmp_div_r(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_div_r(): Argument #1 ($a) must be of type GMP|string|int, resource given +gmp_div_r(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_fact.phpt b/ext/gmp/tests/gmp_fact.phpt index 3829599788..81f16019f0 100644 --- a/ext/gmp/tests/gmp_fact.phpt +++ b/ext/gmp/tests/gmp_fact.phpt @@ -23,12 +23,7 @@ try { echo $e->getMessage() . \PHP_EOL; } -try { - var_dump(gmp_strval(gmp_fact(1.1))); -} catch (\TypeError $e) { - echo $e->getMessage() . \PHP_EOL; -} - +var_dump(gmp_strval(gmp_fact(1.1))); var_dump(gmp_strval(gmp_fact(20))); var_dump(gmp_strval(gmp_fact("50"))); var_dump(gmp_strval(gmp_fact("10"))); @@ -57,12 +52,12 @@ gmp_fact(): Argument #1 ($a) is not an integer string string(1) "1" gmp_fact(): Argument #1 ($a) must be greater than or equal to 0 gmp_fact(): Argument #1 ($a) must be greater than or equal to 0 -gmp_fact(): Argument #1 ($a) must be of type GMP|string|int|bool, float given +string(1) "1" string(19) "2432902008176640000" string(65) "30414093201713378043612608166064768844377641568960512000000000000" string(7) "3628800" string(1) "1" string(9) "479001600" gmp_fact(): Argument #1 ($a) must be greater than or equal to 0 -gmp_fact(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_fact(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_gcdext.phpt b/ext/gmp/tests/gmp_gcdext.phpt index 9619ff7557..abab8cdfdc 100644 --- a/ext/gmp/tests/gmp_gcdext.phpt +++ b/ext/gmp/tests/gmp_gcdext.phpt @@ -63,6 +63,6 @@ string(1) "1" string(1) "1" string(3) "195" string(3) "195" -gmp_gcdext(): Argument #2 ($b) must be of type GMP|string|int|bool, array given -gmp_gcdext(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_gcdext(): Argument #2 ($b) must be of type GMP|string|int, array given +gmp_gcdext(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_hamdist.phpt b/ext/gmp/tests/gmp_hamdist.phpt index ddaea9f0a4..c4b2894941 100644 --- a/ext/gmp/tests/gmp_hamdist.phpt +++ b/ext/gmp/tests/gmp_hamdist.phpt @@ -42,7 +42,7 @@ int(-1) int(43) int(0) int(26) -gmp_hamdist(): Argument #2 ($b) must be of type GMP|string|int|bool, array given -gmp_hamdist(): Argument #1 ($a) must be of type GMP|string|int|bool, array given -gmp_hamdist(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_hamdist(): Argument #2 ($b) must be of type GMP|string|int, array given +gmp_hamdist(): Argument #1 ($a) must be of type GMP|string|int, array given +gmp_hamdist(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_intval.phpt b/ext/gmp/tests/gmp_intval.phpt index 019ab3d070..9540f7a432 100644 --- a/ext/gmp/tests/gmp_intval.phpt +++ b/ext/gmp/tests/gmp_intval.phpt @@ -5,36 +5,47 @@ gmp_intval() tests --FILE-- <?php -var_dump(gmp_intval("")); -var_dump(gmp_intval(1.0001)); -var_dump(gmp_intval("1.0001")); var_dump(gmp_intval("-1")); var_dump(gmp_intval(-1)); var_dump(gmp_intval(-2349828)); var_dump(gmp_intval(2342344)); -var_dump(gmp_intval(new stdclass)); -var_dump(gmp_intval(array())); - -$fp = fopen(__FILE__, 'r'); -var_dump(gmp_intval($fp)); +var_dump(gmp_intval(1.0001)); $g = gmp_init("12345678"); var_dump(gmp_intval($g)); +try { + var_dump(gmp_intval("")); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +try { + var_dump(gmp_intval(new stdclass)); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +try { + var_dump(gmp_intval(array())); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +try { + var_dump(gmp_intval("1.0001")); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} + echo "Done\n"; ?> ---EXPECTF-- -int(0) -int(1) -int(1) +--EXPECT-- int(-1) int(-1) int(-2349828) int(2342344) - -Notice: Object of class stdClass could not be converted to int in %s on line %d int(1) -int(0) -int(%d) int(12345678) +gmp_intval(): Argument #1 ($gmpnumber) is not an integer string +gmp_intval(): Argument #1 ($gmpnumber) must be of type GMP|string|int, stdClass given +gmp_intval(): Argument #1 ($gmpnumber) must be of type GMP|string|int, array given +gmp_intval(): Argument #1 ($gmpnumber) is not an integer string Done diff --git a/ext/gmp/tests/gmp_invert.phpt b/ext/gmp/tests/gmp_invert.phpt index 8ea60b0847..b5ab666061 100644 --- a/ext/gmp/tests/gmp_invert.phpt +++ b/ext/gmp/tests/gmp_invert.phpt @@ -53,7 +53,7 @@ string(1) "0" string(1) "0" string(22) "3498273496234234523441" string(1) "1" -gmp_invert(): Argument #1 ($a) must be of type GMP|string|int|bool, array given -gmp_invert(): Argument #2 ($b) must be of type GMP|string|int|bool, array given -gmp_invert(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_invert(): Argument #1 ($a) must be of type GMP|string|int, array given +gmp_invert(): Argument #2 ($b) must be of type GMP|string|int, array given +gmp_invert(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_jacobi.phpt b/ext/gmp/tests/gmp_jacobi.phpt index 4f40a94828..1164424578 100644 --- a/ext/gmp/tests/gmp_jacobi.phpt +++ b/ext/gmp/tests/gmp_jacobi.phpt @@ -56,7 +56,7 @@ string(1) "0" string(2) "-1" string(1) "0" string(2) "-1" -gmp_jacobi(): Argument #2 ($b) must be of type GMP|string|int|bool, array given -gmp_jacobi(): Argument #1 ($a) must be of type GMP|string|int|bool, array given -gmp_jacobi(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_jacobi(): Argument #2 ($b) must be of type GMP|string|int, array given +gmp_jacobi(): Argument #1 ($a) must be of type GMP|string|int, array given +gmp_jacobi(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_legendre.phpt b/ext/gmp/tests/gmp_legendre.phpt index e52686689e..258e453e4d 100644 --- a/ext/gmp/tests/gmp_legendre.phpt +++ b/ext/gmp/tests/gmp_legendre.phpt @@ -56,7 +56,7 @@ string(1) "0" string(2) "-1" string(1) "0" string(2) "-1" -gmp_legendre(): Argument #2 ($b) must be of type GMP|string|int|bool, array given -gmp_legendre(): Argument #1 ($a) must be of type GMP|string|int|bool, array given -gmp_legendre(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_legendre(): Argument #2 ($b) must be of type GMP|string|int, array given +gmp_legendre(): Argument #1 ($a) must be of type GMP|string|int, array given +gmp_legendre(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_mod.phpt b/ext/gmp/tests/gmp_mod.phpt index a8a56a4d37..90868ab9d9 100644 --- a/ext/gmp/tests/gmp_mod.phpt +++ b/ext/gmp/tests/gmp_mod.phpt @@ -43,7 +43,7 @@ object(GMP)#2 (1) { string(1) "0" } Modulo by zero -gmp_mod(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_mod(): Argument #1 ($a) must be of type GMP|string|int, array given object(GMP)#4 (1) { ["num"]=> string(5) "31161" diff --git a/ext/gmp/tests/gmp_neg.phpt b/ext/gmp/tests/gmp_neg.phpt index 0bded20758..5d8e80cd5b 100644 --- a/ext/gmp/tests/gmp_neg.phpt +++ b/ext/gmp/tests/gmp_neg.phpt @@ -40,5 +40,5 @@ gmp_neg(): Argument #1 ($a) is not an integer string int(0) int(0) string(21) "-12345678901234567890" -gmp_neg(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_neg(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_nextprime.phpt b/ext/gmp/tests/gmp_nextprime.phpt index 6f9e9bfaf6..e2fa2703cb 100644 --- a/ext/gmp/tests/gmp_nextprime.phpt +++ b/ext/gmp/tests/gmp_nextprime.phpt @@ -43,7 +43,7 @@ string(1) "2" string(1) "2" string(4) "1009" string(6) "100003" -gmp_nextprime(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_nextprime(): Argument #1 ($a) must be of type GMP|string|int, array given gmp_nextprime(): Argument #1 ($a) is not an integer string -gmp_nextprime(): Argument #1 ($a) must be of type GMP|string|int|bool, stdClass given +gmp_nextprime(): Argument #1 ($a) must be of type GMP|string|int, stdClass given Done diff --git a/ext/gmp/tests/gmp_or.phpt b/ext/gmp/tests/gmp_or.phpt index ad8f26a87a..5a34a82add 100644 --- a/ext/gmp/tests/gmp_or.phpt +++ b/ext/gmp/tests/gmp_or.phpt @@ -49,7 +49,7 @@ string(3) "-19" gmp_or(): Argument #1 ($a) is not an integer string string(15) "987657876576252" string(21) "987658441719689394144" -gmp_or(): Argument #1 ($a) must be of type GMP|string|int|bool, array given -gmp_or(): Argument #2 ($b) must be of type GMP|string|int|bool, array given -gmp_or(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_or(): Argument #1 ($a) must be of type GMP|string|int, array given +gmp_or(): Argument #2 ($b) must be of type GMP|string|int, array given +gmp_or(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_perfect_square.phpt b/ext/gmp/tests/gmp_perfect_square.phpt index 933b2fe9f9..d6cd09e40e 100644 --- a/ext/gmp/tests/gmp_perfect_square.phpt +++ b/ext/gmp/tests/gmp_perfect_square.phpt @@ -41,5 +41,5 @@ bool(false) bool(false) bool(true) bool(false) -gmp_perfect_square(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_perfect_square(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_popcount.phpt b/ext/gmp/tests/gmp_popcount.phpt index c38cb6f2b8..fa1a6172d4 100644 --- a/ext/gmp/tests/gmp_popcount.phpt +++ b/ext/gmp/tests/gmp_popcount.phpt @@ -28,5 +28,5 @@ int(10) int(31) int(-1) int(20) -gmp_popcount(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_popcount(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_pow.phpt b/ext/gmp/tests/gmp_pow.phpt index b70226bb17..d4d20f2ce7 100644 --- a/ext/gmp/tests/gmp_pow.phpt +++ b/ext/gmp/tests/gmp_pow.phpt @@ -57,5 +57,5 @@ gmp_pow(): Argument #2 ($exp) must be greater than or equal to 0 string(14) "10240000000000" string(14) "10240000000000" gmp_pow(): Argument #2 ($exp) must be of type int, array given -gmp_pow(): Argument #1 ($base) must be of type GMP|string|int|bool, array given +gmp_pow(): Argument #1 ($base) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_pown.phpt b/ext/gmp/tests/gmp_pown.phpt index ae3316b1ad..76d5576e47 100644 --- a/ext/gmp/tests/gmp_pown.phpt +++ b/ext/gmp/tests/gmp_pown.phpt @@ -75,10 +75,10 @@ string(3) "171" string(3) "371" Modulo by zero Modulo by zero -gmp_powm(): Argument #1 ($base) must be of type GMP|string|int|bool, array given -gmp_powm(): Argument #2 ($exp) must be of type GMP|string|int|bool, array given -gmp_powm(): Argument #2 ($exp) must be of type GMP|string|int|bool, TypeError given -gmp_powm(): Argument #1 ($base) must be of type GMP|string|int|bool, array given +gmp_powm(): Argument #1 ($base) must be of type GMP|string|int, array given +gmp_powm(): Argument #2 ($exp) must be of type GMP|string|int, array given +gmp_powm(): Argument #2 ($exp) must be of type GMP|string|int, TypeError given +gmp_powm(): Argument #1 ($base) must be of type GMP|string|int, array given gmp_powm(): Argument #2 ($exp) must be greater than or equal to 0 object(GMP)#6 (1) { ["num"]=> diff --git a/ext/gmp/tests/gmp_prob_prime.phpt b/ext/gmp/tests/gmp_prob_prime.phpt index 15c7aaeaa5..efc5cf4e16 100644 --- a/ext/gmp/tests/gmp_prob_prime.phpt +++ b/ext/gmp/tests/gmp_prob_prime.phpt @@ -75,5 +75,5 @@ int(0) int(0) int(0) int(0) -gmp_prob_prime(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_prob_prime(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_scan0.phpt b/ext/gmp/tests/gmp_scan0.phpt index e7b37d4866..017148c011 100644 --- a/ext/gmp/tests/gmp_scan0.phpt +++ b/ext/gmp/tests/gmp_scan0.phpt @@ -34,5 +34,5 @@ int(0) int(5) int(200) int(13) -gmp_scan0(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_scan0(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_scan1.phpt b/ext/gmp/tests/gmp_scan1.phpt index 9274a659f4..ba480e3e96 100644 --- a/ext/gmp/tests/gmp_scan1.phpt +++ b/ext/gmp/tests/gmp_scan1.phpt @@ -34,5 +34,5 @@ int(12) int(9) int(-1) int(10) -gmp_scan1(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_scan1(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_sign.phpt b/ext/gmp/tests/gmp_sign.phpt index a660ed9e76..01567bb5c4 100644 --- a/ext/gmp/tests/gmp_sign.phpt +++ b/ext/gmp/tests/gmp_sign.phpt @@ -38,5 +38,5 @@ int(1) int(-1) gmp_sign(): Argument #1 ($a) is not an integer string gmp_init(): Argument #1 ($number) is not an integer string -gmp_sign(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_sign(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_sqrt.phpt b/ext/gmp/tests/gmp_sqrt.phpt index 78fa806ba3..19a44121b6 100644 --- a/ext/gmp/tests/gmp_sqrt.phpt +++ b/ext/gmp/tests/gmp_sqrt.phpt @@ -48,5 +48,5 @@ string(2) "12" string(1) "0" gmp_sqrt(): Argument #1 ($a) must be greater than or equal to 0 string(2) "27" -gmp_sqrt(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_sqrt(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_sqrtrem.phpt b/ext/gmp/tests/gmp_sqrtrem.phpt index 819fe217c6..0d63a54ff8 100644 --- a/ext/gmp/tests/gmp_sqrtrem.phpt +++ b/ext/gmp/tests/gmp_sqrtrem.phpt @@ -86,5 +86,5 @@ string(1) "1" gmp_sqrtrem(): Argument #1 ($a) must be greater than or equal to 0 string(4) "1000" string(1) "1" -gmp_sqrtrem(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_sqrtrem(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/gmp_strict_types.phpt b/ext/gmp/tests/gmp_strict_types.phpt new file mode 100644 index 0000000000..8a2b5509a5 --- /dev/null +++ b/ext/gmp/tests/gmp_strict_types.phpt @@ -0,0 +1,55 @@ +--TEST-- +GMP functions with strict_types=1 +--FILE-- +<?php + +declare(strict_types=1); + +var_dump(gmp_abs(gmp_init(-1))); +var_dump(gmp_abs(-1)); +var_dump(gmp_abs("-1")); +try { + gmp_abs(1.0); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +try { + gmp_abs(false); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +try { + gmp_abs(true); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +try { + gmp_abs(null); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +try { + gmp_abs([]); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +object(GMP)#2 (1) { + ["num"]=> + string(1) "1" +} +object(GMP)#2 (1) { + ["num"]=> + string(1) "1" +} +object(GMP)#2 (1) { + ["num"]=> + string(1) "1" +} +gmp_abs(): Argument #1 ($a) must be of type GMP|string|int, float given +gmp_abs(): Argument #1 ($a) must be of type GMP|string|int, bool given +gmp_abs(): Argument #1 ($a) must be of type GMP|string|int, bool given +gmp_abs(): Argument #1 ($a) must be of type GMP|string|int, null given +gmp_abs(): Argument #1 ($a) must be of type GMP|string|int, array given diff --git a/ext/gmp/tests/gmp_strval.phpt b/ext/gmp/tests/gmp_strval.phpt index 722cdfdd8f..234465c294 100644 --- a/ext/gmp/tests/gmp_strval.phpt +++ b/ext/gmp/tests/gmp_strval.phpt @@ -67,7 +67,7 @@ echo "Done\n"; --EXPECT-- gmp_strval(): Argument #1 ($gmpnumber) is not an integer string gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36 -gmp_strval(): Argument #1 ($gmpnumber) must be of type GMP|string|int|bool, resource given +gmp_strval(): Argument #1 ($gmpnumber) must be of type GMP|string|int, resource given string(7) "9765456" gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36 gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36 @@ -76,6 +76,6 @@ string(8) "-3373333" gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36 gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36 string(8) "-3373333" -gmp_strval(): Argument #1 ($gmpnumber) must be of type GMP|string|int|bool, array given -gmp_strval(): Argument #1 ($gmpnumber) must be of type GMP|string|int|bool, stdClass given +gmp_strval(): Argument #1 ($gmpnumber) must be of type GMP|string|int, array given +gmp_strval(): Argument #1 ($gmpnumber) must be of type GMP|string|int, stdClass given Done diff --git a/ext/gmp/tests/gmp_sub.phpt b/ext/gmp/tests/gmp_sub.phpt index 48b1c81092..28a01f86ee 100644 --- a/ext/gmp/tests/gmp_sub.phpt +++ b/ext/gmp/tests/gmp_sub.phpt @@ -38,7 +38,7 @@ echo "Done\n"; ?> --EXPECT-- gmp_sub(): Argument #1 ($a) is not an integer string -gmp_sub(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_sub(): Argument #1 ($a) must be of type GMP|string|int, array given object(GMP)#1 (1) { ["num"]=> string(2) "-1" @@ -49,6 +49,6 @@ object(GMP)#3 (1) { string(5) "10001" } string(5) "10001" -gmp_sub(): Argument #2 ($b) must be of type GMP|string|int|bool, stdClass given -gmp_sub(): Argument #1 ($a) must be of type GMP|string|int|bool, stdClass given +gmp_sub(): Argument #2 ($b) must be of type GMP|string|int, stdClass given +gmp_sub(): Argument #1 ($a) must be of type GMP|string|int, stdClass given Done diff --git a/ext/gmp/tests/gmp_xor.phpt b/ext/gmp/tests/gmp_xor.phpt index fadcd0086e..d81b5947fc 100644 --- a/ext/gmp/tests/gmp_xor.phpt +++ b/ext/gmp/tests/gmp_xor.phpt @@ -49,7 +49,7 @@ string(5) "-4563" gmp_xor(): Argument #1 ($a) is not an integer string string(15) "987657876574716" string(21) "987658017016065701376" -gmp_xor(): Argument #1 ($a) must be of type GMP|string|int|bool, array given -gmp_xor(): Argument #2 ($b) must be of type GMP|string|int|bool, array given -gmp_xor(): Argument #1 ($a) must be of type GMP|string|int|bool, array given +gmp_xor(): Argument #1 ($a) must be of type GMP|string|int, array given +gmp_xor(): Argument #2 ($b) must be of type GMP|string|int, array given +gmp_xor(): Argument #1 ($a) must be of type GMP|string|int, array given Done diff --git a/ext/gmp/tests/overloading.phpt b/ext/gmp/tests/overloading.phpt index e0fa6deb17..75eafa3ee5 100644 --- a/ext/gmp/tests/overloading.phpt +++ b/ext/gmp/tests/overloading.phpt @@ -282,7 +282,7 @@ bool(false) bool(true) bool(false) bool(true) -main(): Argument #2 must be of type GMP|string|int|bool, stdClass given +main(): Argument #2 must be of type GMP|string|int, stdClass given object(GMP)#4 (1) { ["num"]=> string(2) "43" |