Skip to content

Commit ac84c28

Browse files
committed
Warning to error in parse_ini_file()
1 parent ab5f8f4 commit ac84c28

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

ext/standard/array.c

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6174,39 +6174,19 @@ PHP_FUNCTION(array_map)
61746174
PHP_FUNCTION(array_key_exists)
61756175
{
61766176
zval *key;
6177+
zend_string *string_key;
6178+
zend_long int_key;
61776179
HashTable *ht;
61786180

61796181
ZEND_PARSE_PARAMETERS_START(2, 2)
6180-
Z_PARAM_ZVAL(key)
6182+
Z_PARAM_STR_OR_LONG(string_key, int_key)
61816183
Z_PARAM_ARRAY_HT(ht)
61826184
ZEND_PARSE_PARAMETERS_END();
61836185

6184-
switch (Z_TYPE_P(key)) {
6185-
case IS_STRING:
6186-
RETVAL_BOOL(zend_symtable_exists_ind(ht, Z_STR_P(key)));
6187-
break;
6188-
case IS_LONG:
6189-
RETVAL_BOOL(zend_hash_index_exists(ht, Z_LVAL_P(key)));
6190-
break;
6191-
case IS_NULL:
6192-
RETVAL_BOOL(zend_hash_exists_ind(ht, ZSTR_EMPTY_ALLOC()));
6193-
break;
6194-
case IS_DOUBLE:
6195-
RETVAL_BOOL(zend_hash_index_exists(ht, zend_dval_to_lval(Z_DVAL_P(key))));
6196-
break;
6197-
case IS_FALSE:
6198-
RETVAL_BOOL(zend_hash_index_exists(ht, 0));
6199-
break;
6200-
case IS_TRUE:
6201-
RETVAL_BOOL(zend_hash_index_exists(ht, 1));
6202-
break;
6203-
case IS_RESOURCE:
6204-
zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(key), Z_RES_HANDLE_P(key));
6205-
RETVAL_BOOL(zend_hash_index_exists(ht, Z_RES_HANDLE_P(key)));
6206-
break;
6207-
default:
6208-
zend_argument_type_error(1, "must be a valid array offset type");
6209-
break;
6186+
if (string_key) {
6187+
RETVAL_BOOL(zend_symtable_exists_ind(ht, string_key));
6188+
} else {
6189+
RETVAL_BOOL(zend_hash_index_exists(ht, int_key));
62106190
}
62116191
}
62126192
/* }}} */

ext/standard/basic_functions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,8 +2653,8 @@ PHP_FUNCTION(parse_ini_file)
26532653
ZEND_PARSE_PARAMETERS_END();
26542654

26552655
if (filename_len == 0) {
2656-
php_error_docref(NULL, E_WARNING, "Filename cannot be empty!");
2657-
RETURN_FALSE;
2656+
zend_argument_value_error(1, "cannot be empty");
2657+
RETURN_THROWS();
26582658
}
26592659

26602660
/* Set callback function */

0 commit comments

Comments
 (0)