summaryrefslogtreecommitdiff
path: root/ext/standard/array.c
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2019-08-20 23:11:11 +0200
committerGeorge Peter Banyard <girgias@php.net>2019-08-21 18:05:08 +0200
commit7c6acc2eefcaf1b3fd03b1730db84f1f58fffec6 (patch)
treee89168b31728b7594c3b867b4b39e0e3856d1d58 /ext/standard/array.c
parent5b8e12a99b5fd2a314b9b3e5bb97122464379c85 (diff)
downloadphp-git-7c6acc2eefcaf1b3fd03b1730db84f1f58fffec6.tar.gz
Promote warnings to errors in range()
Diffstat (limited to 'ext/standard/array.c')
-rw-r--r--ext/standard/array.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 70523d479e..b99d3222dc 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -2704,8 +2704,9 @@ 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) { \
- php_error_docref(NULL, E_WARNING, "The supplied range exceeds the maximum array size: start=%0.0f end=%0.0f", end, start); \
- RETURN_FALSE; \
+ zend_throw_error(NULL, \
+ "The supplied range exceeds the maximum array size: start=%0.0f end=%0.0f", end, start); \
+ return; \
} \
size = (uint32_t)_php_math_round(__calc_size, 0, PHP_ROUND_HALF_UP); \
array_init_size(return_value, size); \
@@ -2715,15 +2716,16 @@ 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) { \
- php_error_docref(NULL, E_WARNING, "The supplied range exceeds the maximum array size: start=" ZEND_LONG_FMT " end=" ZEND_LONG_FMT, end, start); \
- RETURN_FALSE; \
+ zend_throw_error(NULL, \
+ "The supplied range exceeds the maximum array size: start=" ZEND_LONG_FMT " end=" ZEND_LONG_FMT, end, start); \
+ return; \
} \
size = (uint32_t)(__calc_size + 1); \
array_init_size(return_value, size); \
zend_hash_real_init_packed(Z_ARRVAL_P(return_value)); \
} while (0)
-/* {{{ proto array|false range(mixed low, mixed high[, int step])
+/* {{{ proto array range(mixed low, mixed high[, int step])
Create an array containing the range of integers or characters from low to high (inclusive) */
PHP_FUNCTION(range)
{
@@ -2812,8 +2814,8 @@ double_str:
high = zval_get_double(zhigh);
if (zend_isinf(high) || zend_isinf(low)) {
- php_error_docref(NULL, E_WARNING, "Invalid range supplied: start=%0.0f end=%0.0f", low, high);
- RETURN_FALSE;
+ zend_throw_error(NULL, "Invalid range supplied: start=%0.0f end=%0.0f", low, high);
+ return;
}
if (low > high) { /* Negative steps */
@@ -2905,8 +2907,8 @@ long_str:
}
err:
if (err) {
- php_error_docref(NULL, E_WARNING, "step exceeds the specified range");
- RETURN_FALSE;
+ zend_throw_error(NULL, "step exceeds the specified range");
+ return;
}
}
/* }}} */