diff options
author | George Peter Banyard <girgias@php.net> | 2019-11-18 23:40:02 +0100 |
---|---|---|
committer | George Peter Banyard <girgias@php.net> | 2019-12-05 14:22:54 +0100 |
commit | 5fbd49f9abc058ea3040ce00b2225e4cc46ce650 (patch) | |
tree | bc360e1afe2a91c149bcc55174fcb521a97a1bc7 /ext/standard/array.c | |
parent | 73730eebca0fa765fb8df5806a48d0ce268940a8 (diff) | |
download | php-git-5fbd49f9abc058ea3040ce00b2225e4cc46ce650.tar.gz |
Convert Errors to ValueErrors
Closes GH-4930
Diffstat (limited to 'ext/standard/array.c')
-rw-r--r-- | ext/standard/array.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index c11ba58868..618ff2a2d1 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1263,7 +1263,7 @@ PHP_FUNCTION(min) if ((result = zend_hash_minmax(Z_ARRVAL(args[0]), php_array_data_compare, 0)) != NULL) { ZVAL_COPY_DEREF(return_value, result); } else { - zend_throw_error(NULL, "Array must contain at least one element"); + zend_value_error("Array must contain at least one element"); return; } } @@ -1310,7 +1310,7 @@ PHP_FUNCTION(max) if ((result = zend_hash_minmax(Z_ARRVAL(args[0]), php_array_data_compare, 1)) != NULL) { ZVAL_COPY_DEREF(return_value, result); } else { - zend_throw_error(NULL, "Array must contain at least one element"); + zend_value_error("Array must contain at least one element"); return; } } @@ -2451,18 +2451,18 @@ PHP_FUNCTION(extract) extract_type &= 0xff; if (extract_type < EXTR_OVERWRITE || extract_type > EXTR_IF_EXISTS) { - zend_throw_error(NULL, "Invalid extract type"); + zend_value_error("Invalid extract type"); return; } if (extract_type > EXTR_SKIP && extract_type <= EXTR_PREFIX_IF_EXISTS && ZEND_NUM_ARGS() < 3) { - zend_throw_error(NULL, "Specified extract type requires the prefix parameter"); + zend_value_error("Specified extract type requires the prefix parameter"); return; } if (prefix) { if (ZSTR_LEN(prefix) && !php_valid_var_name(ZSTR_VAL(prefix), ZSTR_LEN(prefix))) { - zend_throw_error(NULL, "Prefix is not a valid identifier"); + zend_value_error("Prefix is not a valid identifier"); return; } } @@ -2619,7 +2619,7 @@ PHP_FUNCTION(array_fill) if (EXPECTED(num > 0)) { if (sizeof(num) > 4 && UNEXPECTED(EXPECTED(num > 0x7fffffff))) { - zend_throw_error(NULL, "Too many elements"); + zend_value_error("Too many elements"); return; } else if (UNEXPECTED(start_key > ZEND_LONG_MAX - num + 1)) { zend_throw_error(NULL, "Cannot add element to the array as the next element is already occupied"); @@ -2668,7 +2668,7 @@ PHP_FUNCTION(array_fill) } else if (EXPECTED(num == 0)) { RETURN_EMPTY_ARRAY(); } else { - zend_throw_error(NULL, "Number of elements can't be negative"); + zend_value_error("Number of elements can't be negative"); return; } } @@ -2706,7 +2706,7 @@ PHP_FUNCTION(array_fill_keys) #define RANGE_CHECK_DOUBLE_INIT_ARRAY(start, end) do { \ double __calc_size = ((start - end) / step) + 1; \ if (__calc_size >= (double)HT_MAX_SIZE) { \ - zend_throw_error(NULL, \ + zend_value_error(\ "The supplied range exceeds the maximum array size: start=%0.0f end=%0.0f", end, start); \ return; \ } \ @@ -2718,7 +2718,7 @@ PHP_FUNCTION(array_fill_keys) #define RANGE_CHECK_LONG_INIT_ARRAY(start, end) do { \ zend_ulong __calc_size = ((zend_ulong) start - end) / lstep; \ if (__calc_size >= HT_MAX_SIZE - 1) { \ - zend_throw_error(NULL, \ + zend_value_error(\ "The supplied range exceeds the maximum array size: start=" ZEND_LONG_FMT " end=" ZEND_LONG_FMT, end, start); \ return; \ } \ @@ -2816,7 +2816,7 @@ double_str: high = zval_get_double(zhigh); if (zend_isinf(high) || zend_isinf(low)) { - zend_throw_error(NULL, "Invalid range supplied: start=%0.0f end=%0.0f", low, high); + zend_value_error("Invalid range supplied: start=%0.0f end=%0.0f", low, high); return; } @@ -2909,7 +2909,7 @@ long_str: } err: if (err) { - zend_throw_error(NULL, "step exceeds the specified range"); + zend_value_error("step exceeds the specified range"); return; } } @@ -4389,7 +4389,7 @@ PHP_FUNCTION(array_pad) input_size = zend_hash_num_elements(Z_ARRVAL_P(input)); pad_size_abs = ZEND_ABS(pad_size); if (pad_size_abs < 0 || pad_size_abs - input_size > Z_L(1048576)) { - zend_throw_error(NULL, "You may only pad up to 1048576 elements at a time"); + zend_value_error("You may only pad up to 1048576 elements at a time"); return; } @@ -5769,7 +5769,7 @@ PHP_FUNCTION(array_multisort) array_size = zend_hash_num_elements(Z_ARRVAL_P(arrays[0])); for (i = 0; i < num_arrays; i++) { if (zend_hash_num_elements(Z_ARRVAL_P(arrays[i])) != (uint32_t)array_size) { - zend_throw_error(NULL, "Array sizes are inconsistent"); + zend_value_error("Array sizes are inconsistent"); MULTISORT_ABORT; } } @@ -5865,7 +5865,7 @@ PHP_FUNCTION(array_rand) num_avail = zend_hash_num_elements(Z_ARRVAL_P(input)); if (num_avail == 0) { - zend_throw_error(NULL, "Array is empty"); + zend_value_error("Array is empty"); return; } @@ -5906,7 +5906,7 @@ PHP_FUNCTION(array_rand) } if (num_req <= 0 || num_req > num_avail) { - zend_throw_error(NULL, "Second argument has to be between 1 and the number of elements in the array"); + zend_value_error("Second argument has to be between 1 and the number of elements in the array"); return; } @@ -6395,7 +6395,7 @@ PHP_FUNCTION(array_chunk) /* Do bounds checking for size parameter. */ if (size < 1) { - zend_throw_error(NULL, "Size parameter expected to be greater than 0"); + zend_value_error("Size parameter expected to be greater than 0"); return; } @@ -6460,7 +6460,7 @@ PHP_FUNCTION(array_combine) num_values = zend_hash_num_elements(values); if (num_keys != num_values) { - zend_throw_error(NULL, "Both parameters should have an equal number of elements"); + zend_value_error("Both parameters should have an equal number of elements"); return; } |