Skip to content

Commit ee3b345

Browse files
committed
Promote warning to exception in ini_get_all() function
1 parent 441b326 commit ee3b345

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
@@ -363,7 +363,7 @@ static const func_info_t func_infos[] = {
363363
F1("highlight_string", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
364364
F1("php_strip_whitespace", MAY_BE_STRING),
365365
FN("ini_get", MAY_BE_FALSE | MAY_BE_STRING),
366-
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),
366+
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),
367367
FN("ini_set", MAY_BE_FALSE | MAY_BE_STRING),
368368
F1("ini_alter", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
369369
F0("ini_restore", MAY_BE_NULL),

ext/standard/basic_functions.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3556,7 +3556,7 @@ PHP_FUNCTION(ini_get)
35563556
}
35573557
/* }}} */
35583558

3559-
/* {{{ proto array|false ini_get_all([string extension[, bool details = true]])
3559+
/* {{{ proto array ini_get_all([string extension[, bool details = true]])
35603560
Get all configuration options */
35613561
PHP_FUNCTION(ini_get_all)
35623562
{
@@ -3567,7 +3567,6 @@ PHP_FUNCTION(ini_get_all)
35673567
zend_string *key;
35683568
zend_ini_entry *ini_entry;
35693569

3570-
35713570
ZEND_PARSE_PARAMETERS_START(0, 2)
35723571
Z_PARAM_OPTIONAL
35733572
Z_PARAM_STRING_OR_NULL(extname, extname_len)
@@ -3578,8 +3577,8 @@ PHP_FUNCTION(ini_get_all)
35783577

35793578
if (extname) {
35803579
if ((module = zend_hash_str_find_ptr(&module_registry, extname, extname_len)) == NULL) {
3581-
php_error_docref(NULL, E_WARNING, "Unable to find extension '%s'", extname);
3582-
RETURN_FALSE;
3580+
zend_value_error("Unable to find extension '%s'", extname);
3581+
return;
35833582
}
35843583
module_number = module->module_number;
35853584
}

ext/standard/basic_functions.stub.php

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

316316
function ini_get(string $varname): string|false {}
317317

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

320320
function ini_set(string $varname, string $value): string|false {}
321321

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

362362
function move_uploaded_file(string $path, string $new_path): bool {}
363363

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

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

ext/standard/basic_functions_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ini_get, 0, 1, MAY_BE_STRING|MAY
480480
ZEND_ARG_TYPE_INFO(0, varname, IS_STRING, 0)
481481
ZEND_END_ARG_INFO()
482482

483-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ini_get_all, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE)
483+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ini_get_all, 0, 0, IS_ARRAY, 0)
484484
ZEND_ARG_TYPE_INFO(0, extension, IS_STRING, 1)
485485
ZEND_ARG_TYPE_INFO(0, details, _IS_BOOL, 0)
486486
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)