Skip to content

Commit e6b3915

Browse files
committed
Promote warning to exception in ini_get_all() function
1 parent 725c2a9 commit e6b3915

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

ext/opcache/Optimizer/zend_func_info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ static const func_info_t func_infos[] = {
295295
F1("highlight_string", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
296296
F1("php_strip_whitespace", MAY_BE_STRING),
297297
FN("ini_get", MAY_BE_FALSE | MAY_BE_STRING),
298-
F1("ini_get_all", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
298+
F1("ini_get_all", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
299299
FN("ini_set", MAY_BE_FALSE | MAY_BE_STRING),
300300
F1("ini_alter", MAY_BE_FALSE | MAY_BE_STRING),
301301
F1("get_include_path", MAY_BE_FALSE | MAY_BE_STRING),

ext/standard/basic_functions.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,7 +3194,7 @@ PHP_FUNCTION(ini_get)
31943194
}
31953195
/* }}} */
31963196

3197-
/* {{{ proto array|false ini_get_all([string extension[, bool details = true]])
3197+
/* {{{ proto array ini_get_all([string extension[, bool details = true]])
31983198
Get all configuration options */
31993199
PHP_FUNCTION(ini_get_all)
32003200
{
@@ -3205,7 +3205,6 @@ PHP_FUNCTION(ini_get_all)
32053205
zend_string *key;
32063206
zend_ini_entry *ini_entry;
32073207

3208-
32093208
ZEND_PARSE_PARAMETERS_START(0, 2)
32103209
Z_PARAM_OPTIONAL
32113210
Z_PARAM_STRING_OR_NULL(extname, extname_len)
@@ -3216,8 +3215,8 @@ PHP_FUNCTION(ini_get_all)
32163215

32173216
if (extname) {
32183217
if ((module = zend_hash_str_find_ptr(&module_registry, extname, extname_len)) == NULL) {
3219-
php_error_docref(NULL, E_WARNING, "Unable to find extension '%s'", extname);
3220-
RETURN_FALSE;
3218+
zend_value_error("Unable to find extension '%s'", extname);
3219+
return;
32213220
}
32223221
module_number = module->module_number;
32233222
}

ext/standard/basic_functions.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ function highlight_string(string $string, bool $return = false): string|bool|nul
311311

312312
function ini_get(string $varname): string|false {}
313313

314-
function ini_get_all(?string $extension = null, bool $details = true): array|false {}
314+
function ini_get_all(?string $extension = null, bool $details = true): array {}
315315

316316
function ini_set(string $varname, string $value): string|false {}
317317

@@ -357,7 +357,7 @@ function is_uploaded_file(string $path): bool {}
357357

358358
function move_uploaded_file(string $path, string $new_path): bool {}
359359

360-
function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array|false {}
360+
function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array {}
361361

362362
function parse_ini_string(string $ini_string, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array|false {}
363363

ext/standard/basic_functions_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ini_get, 0, 1, MAY_BE_STRING|MAY
476476
ZEND_ARG_TYPE_INFO(0, varname, IS_STRING, 0)
477477
ZEND_END_ARG_INFO()
478478

479-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ini_get_all, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE)
479+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ini_get_all, 0, 0, IS_ARRAY, 0)
480480
ZEND_ARG_TYPE_INFO(0, extension, IS_STRING, 1)
481481
ZEND_ARG_TYPE_INFO(0, details, _IS_BOOL, 0)
482482
ZEND_END_ARG_INFO()

ext/standard/tests/general_functions/ini_get_all.phpt

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,32 @@ pcre.recursion_limit=100000
1010
<?php
1111

1212
var_dump(gettype(ini_get_all()));
13-
var_dump(ini_get_all(""));
14-
var_dump(ini_get_all("nosuchextension"));
13+
try {
14+
ini_get_all("");
15+
} catch (ValueError $exception) {
16+
echo $exception->getMessage() . "\n";
17+
}
18+
try {
19+
var_dump(ini_get_all("nosuchextension"));
20+
} catch (ValueError $exception) {
21+
echo $exception->getMessage() . "\n";
22+
}
1523
var_dump(ini_get_all("reflection"));
1624
var_dump(ini_get_all("pcre"));
1725
var_dump(ini_get_all("pcre", false));
1826
var_dump(ini_get_all("reflection", false));
19-
20-
var_dump(ini_get_all("", ""));
27+
try {
28+
ini_get_all("", "");
29+
} catch (ValueError $exception) {
30+
echo $exception->getMessage() . "\n";
31+
}
2132

2233
echo "Done\n";
2334
?>
24-
--EXPECTF--
35+
--EXPECT--
2536
string(5) "array"
26-
27-
Warning: ini_get_all(): Unable to find extension '' in %s on line %d
28-
bool(false)
29-
30-
Warning: ini_get_all(): Unable to find extension 'nosuchextension' in %s on line %d
31-
bool(false)
37+
Unable to find extension ''
38+
Unable to find extension 'nosuchextension'
3239
array(0) {
3340
}
3441
array(3) {
@@ -70,7 +77,5 @@ array(3) {
7077
}
7178
array(0) {
7279
}
73-
74-
Warning: ini_get_all(): Unable to find extension '' in %sini_get_all.php on line %d
75-
bool(false)
80+
Unable to find extension ''
7681
Done

0 commit comments

Comments
 (0)