Skip to content

Commit 7542687

Browse files
Closes #5270
1 parent 4356448 commit 7542687

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

ChangeLog-9.6.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes of the PHPUnit 9.6 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
44

5+
## [9.6.6] - 2023-MM-DD
6+
7+
### Fixed
8+
9+
* [#5270](https://github.com/sebastianbergmann/phpunit/issues/5270): `GlobalState::getIniSettingsAsString()` generates code that triggers warnings
10+
511
## [9.6.5] - 2023-03-09
612

713
### Changed
@@ -46,6 +52,7 @@ All notable changes of the PHPUnit 9.6 release series are documented in this fil
4652
* [#5064](https://github.com/sebastianbergmann/phpunit/issues/5064): Deprecate `PHPUnit\Framework\TestCase::getMockClass()`
4753
* [#5132](https://github.com/sebastianbergmann/phpunit/issues/5132): Deprecate `Test` suffix for abstract test case classes
4854

55+
[9.6.6]: https://github.com/sebastianbergmann/phpunit/compare/9.6.5...9.6
4956
[9.6.5]: https://github.com/sebastianbergmann/phpunit/compare/9.6.4...9.6.5
5057
[9.6.4]: https://github.com/sebastianbergmann/phpunit/compare/9.6.3...9.6.4
5158
[9.6.3]: https://github.com/sebastianbergmann/phpunit/compare/9.6.2...9.6.3

src/Util/GlobalState.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*/
1010
namespace PHPUnit\Util;
1111

12+
use const PHP_MAJOR_VERSION;
13+
use const PHP_MINOR_VERSION;
1214
use function array_keys;
1315
use function array_reverse;
1416
use function array_shift;
@@ -47,6 +49,79 @@ final class GlobalState
4749
'_REQUEST',
4850
];
4951

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+
50125
/**
51126
* @throws Exception
52127
*/
@@ -106,6 +181,10 @@ public static function getIniSettingsAsString(): string
106181
$result = '';
107182

108183
foreach (ini_get_all(null, false) as $key => $value) {
184+
if (self::isIniSettingDeprecated($key)) {
185+
continue;
186+
}
187+
109188
$result .= sprintf(
110189
'@ini_set(%s, %s);' . "\n",
111190
self::exportVariable($key),
@@ -200,4 +279,9 @@ private static function arrayOnlyContainsScalars(array $array): bool
200279

201280
return $result;
202281
}
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+
}
203287
}

0 commit comments

Comments
 (0)