|
9 | 9 | */ |
10 | 10 | namespace PHPUnit\Util; |
11 | 11 |
|
| 12 | +use const PHP_MAJOR_VERSION; |
| 13 | +use const PHP_MINOR_VERSION; |
12 | 14 | use function array_keys; |
13 | 15 | use function array_reverse; |
14 | 16 | use function array_shift; |
@@ -47,6 +49,79 @@ final class GlobalState |
47 | 49 | '_REQUEST', |
48 | 50 | ]; |
49 | 51 |
|
| 52 | + /** |
| 53 | + * @psalm-var array<string, array<string, true>> |
| 54 | + */ |
| 55 | + private const DEPRECATED_INI_SETTINGS = [ |
| 56 | + '7.3' => [ |
| 57 | + 'iconv.input_encoding' => true, |
| 58 | + 'iconv.output_encoding' => true, |
| 59 | + 'iconv.internal_encoding' => true, |
| 60 | + 'mbstring.func_overload' => true, |
| 61 | + 'mbstring.http_input' => true, |
| 62 | + 'mbstring.http_output' => true, |
| 63 | + 'mbstring.internal_encoding' => true, |
| 64 | + 'string.strip_tags' => true, |
| 65 | + ], |
| 66 | + |
| 67 | + '7.4' => [ |
| 68 | + 'iconv.input_encoding' => true, |
| 69 | + 'iconv.output_encoding' => true, |
| 70 | + 'iconv.internal_encoding' => true, |
| 71 | + 'mbstring.func_overload' => true, |
| 72 | + 'mbstring.http_input' => true, |
| 73 | + 'mbstring.http_output' => true, |
| 74 | + 'mbstring.internal_encoding' => true, |
| 75 | + 'pdo_odbc.db2_instance_name' => true, |
| 76 | + 'string.strip_tags' => true, |
| 77 | + ], |
| 78 | + |
| 79 | + '8.0' => [ |
| 80 | + 'iconv.input_encoding' => true, |
| 81 | + 'iconv.output_encoding' => true, |
| 82 | + 'iconv.internal_encoding' => true, |
| 83 | + 'mbstring.http_input' => true, |
| 84 | + 'mbstring.http_output' => true, |
| 85 | + 'mbstring.internal_encoding' => true, |
| 86 | + ], |
| 87 | + |
| 88 | + '8.1' => [ |
| 89 | + 'auto_detect_line_endings' => true, |
| 90 | + 'filter.default' => true, |
| 91 | + 'iconv.input_encoding' => true, |
| 92 | + 'iconv.output_encoding' => true, |
| 93 | + 'iconv.internal_encoding' => true, |
| 94 | + 'mbstring.http_input' => true, |
| 95 | + 'mbstring.http_output' => true, |
| 96 | + 'mbstring.internal_encoding' => true, |
| 97 | + 'oci8.old_oci_close_semantics' => true, |
| 98 | + ], |
| 99 | + |
| 100 | + '8.2' => [ |
| 101 | + 'auto_detect_line_endings' => true, |
| 102 | + 'filter.default' => true, |
| 103 | + 'iconv.input_encoding' => true, |
| 104 | + 'iconv.output_encoding' => true, |
| 105 | + 'iconv.internal_encoding' => true, |
| 106 | + 'mbstring.http_input' => true, |
| 107 | + 'mbstring.http_output' => true, |
| 108 | + 'mbstring.internal_encoding' => true, |
| 109 | + 'oci8.old_oci_close_semantics' => true, |
| 110 | + ], |
| 111 | + |
| 112 | + '8.3' => [ |
| 113 | + 'auto_detect_line_endings' => true, |
| 114 | + 'filter.default' => true, |
| 115 | + 'iconv.input_encoding' => true, |
| 116 | + 'iconv.output_encoding' => true, |
| 117 | + 'iconv.internal_encoding' => true, |
| 118 | + 'mbstring.http_input' => true, |
| 119 | + 'mbstring.http_output' => true, |
| 120 | + 'mbstring.internal_encoding' => true, |
| 121 | + 'oci8.old_oci_close_semantics' => true, |
| 122 | + ], |
| 123 | + ]; |
| 124 | + |
50 | 125 | /** |
51 | 126 | * @throws Exception |
52 | 127 | */ |
@@ -106,6 +181,10 @@ public static function getIniSettingsAsString(): string |
106 | 181 | $result = ''; |
107 | 182 |
|
108 | 183 | foreach (ini_get_all(null, false) as $key => $value) { |
| 184 | + if (self::isIniSettingDeprecated($key)) { |
| 185 | + continue; |
| 186 | + } |
| 187 | + |
109 | 188 | $result .= sprintf( |
110 | 189 | '@ini_set(%s, %s);' . "\n", |
111 | 190 | self::exportVariable($key), |
@@ -200,4 +279,9 @@ private static function arrayOnlyContainsScalars(array $array): bool |
200 | 279 |
|
201 | 280 | return $result; |
202 | 281 | } |
| 282 | + |
| 283 | + private static function isIniSettingDeprecated(string $iniSetting): bool |
| 284 | + { |
| 285 | + return isset(self::DEPRECATED_INI_SETTINGS[PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION][$iniSetting]); |
| 286 | + } |
203 | 287 | } |
0 commit comments