Skip to content

Commit 63ea7e4

Browse files
committed
ext/standard/array.c: Use more appropriate type
1 parent 2f25e51 commit 63ea7e4

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

ext/standard/array.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3711,7 +3711,7 @@ PHP_FUNCTION(array_splice)
37113711
/* ..and the length */
37123712
if (length < 0) {
37133713
size = num_in - offset + length;
3714-
} else if (((zend_ulong) offset + (zend_ulong) length) > (uint32_t) num_in) {
3714+
} else if (((zend_ulong) offset + (zend_ulong) length) > num_in) {
37153715
size = num_in - offset;
37163716
}
37173717

@@ -6638,8 +6638,7 @@ PHP_FUNCTION(array_map)
66386638
zval result;
66396639
zend_fcall_info fci;
66406640
zend_fcall_info_cache fci_cache;
6641-
uint32_t i;
6642-
uint32_t k, maxlen = 0;
6641+
uint32_t maxlen = 0;
66436642

66446643
ZEND_PARSE_PARAMETERS_START(2, -1)
66456644
Z_PARAM_FUNC_OR_NULL(fci, fci_cache)
@@ -6712,7 +6711,7 @@ PHP_FUNCTION(array_map)
67126711
} ZEND_HASH_FOREACH_END();
67136712
}
67146713
} else {
6715-
for (i = 0; i < n_arrays; i++) {
6714+
for (uint32_t i = 0; i < n_arrays; i++) {
67166715
if (Z_TYPE(arrays[i]) != IS_ARRAY) {
67176716
zend_argument_type_error(i + 2, "must be of type array, %s given", zend_zval_value_name(&arrays[i]));
67186717
RETURN_THROWS();
@@ -6729,13 +6728,13 @@ PHP_FUNCTION(array_map)
67296728
zval zv;
67306729

67316730
/* We iterate through all the arrays at once. */
6732-
for (k = 0; k < maxlen; k++) {
6731+
for (uint32_t k = 0; k < maxlen; k++) {
67336732

67346733
/* If no callback, the result will be an array, consisting of current
67356734
* entries from all arrays. */
67366735
array_init_size(&result, n_arrays);
67376736

6738-
for (i = 0; i < n_arrays; i++) {
6737+
for (uint32_t i = 0; i < n_arrays; i++) {
67396738
/* If this array still has elements, add the current one to the
67406739
* parameter list, otherwise use null value. */
67416740
uint32_t pos = array_pos[i];
@@ -6775,7 +6774,7 @@ PHP_FUNCTION(array_map)
67756774
zval *params = (zval *)safe_emalloc(n_arrays, sizeof(zval), 0);
67766775

67776776
/* Remember next starting point in the array, initialize those as zeros. */
6778-
for (i = 0; i < n_arrays; i++) {
6777+
for (uint32_t i = 0; i < n_arrays; i++) {
67796778
Z_EXTRA(params[i]) = 0;
67806779
}
67816780

@@ -6784,8 +6783,8 @@ PHP_FUNCTION(array_map)
67846783
fci.params = params;
67856784

67866785
/* We iterate through all the arrays at once. */
6787-
for (k = 0; k < maxlen; k++) {
6788-
for (i = 0; i < n_arrays; i++) {
6786+
for (uint32_t k = 0; k < maxlen; k++) {
6787+
for (uint32_t i = 0; i < n_arrays; i++) {
67896788
/* If this array still has elements, add the current one to the
67906789
* parameter list, otherwise use null value. */
67916790
uint32_t pos = Z_EXTRA(params[i]);
@@ -6879,7 +6878,6 @@ PHP_FUNCTION(array_key_exists)
68796878
/* {{{ Split array into chunks */
68806879
PHP_FUNCTION(array_chunk)
68816880
{
6882-
int num_in;
68836881
zend_long size, current = 0;
68846882
zend_string *str_key;
68856883
zend_ulong num_key;
@@ -6901,7 +6899,7 @@ PHP_FUNCTION(array_chunk)
69016899
RETURN_THROWS();
69026900
}
69036901

6904-
num_in = zend_hash_num_elements(Z_ARRVAL_P(input));
6902+
uint32_t num_in = zend_hash_num_elements(Z_ARRVAL_P(input));
69056903

69066904
if (size > num_in) {
69076905
if (num_in == 0) {
@@ -6945,15 +6943,14 @@ PHP_FUNCTION(array_combine)
69456943
HashTable *values, *keys;
69466944
uint32_t pos_values = 0;
69476945
zval *entry_keys, *entry_values;
6948-
int num_keys, num_values;
69496946

69506947
ZEND_PARSE_PARAMETERS_START(2, 2)
69516948
Z_PARAM_ARRAY_HT(keys)
69526949
Z_PARAM_ARRAY_HT(values)
69536950
ZEND_PARSE_PARAMETERS_END();
69546951

6955-
num_keys = zend_hash_num_elements(keys);
6956-
num_values = zend_hash_num_elements(values);
6952+
uint32_t num_keys = zend_hash_num_elements(keys);
6953+
uint32_t num_values = zend_hash_num_elements(values);
69576954

69586955
if (num_keys != num_values) {
69596956
zend_argument_value_error(1, "and argument #2 ($values) must have the same number of elements");

0 commit comments

Comments
 (0)