Skip to content

Commit

Permalink
Closes #5270
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 23, 2023
1 parent 4356448 commit 7542687
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ChangeLog-9.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## [9.6.6] - 2023-MM-DD

### Fixed

* [#5270](https://github.com/sebastianbergmann/phpunit/issues/5270): `GlobalState::getIniSettingsAsString()` generates code that triggers warnings

## [9.6.5] - 2023-03-09

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

[9.6.6]: https://github.com/sebastianbergmann/phpunit/compare/9.6.5...9.6
[9.6.5]: https://github.com/sebastianbergmann/phpunit/compare/9.6.4...9.6.5
[9.6.4]: https://github.com/sebastianbergmann/phpunit/compare/9.6.3...9.6.4
[9.6.3]: https://github.com/sebastianbergmann/phpunit/compare/9.6.2...9.6.3
Expand Down
84 changes: 84 additions & 0 deletions src/Util/GlobalState.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/
namespace PHPUnit\Util;

use const PHP_MAJOR_VERSION;
use const PHP_MINOR_VERSION;
use function array_keys;
use function array_reverse;
use function array_shift;
Expand Down Expand Up @@ -47,6 +49,79 @@ final class GlobalState
'_REQUEST',
];

/**
* @psalm-var array<string, array<string, true>>
*/
private const DEPRECATED_INI_SETTINGS = [
'7.3' => [
'iconv.input_encoding' => true,
'iconv.output_encoding' => true,
'iconv.internal_encoding' => true,
'mbstring.func_overload' => true,
'mbstring.http_input' => true,
'mbstring.http_output' => true,
'mbstring.internal_encoding' => true,
'string.strip_tags' => true,
],

'7.4' => [
'iconv.input_encoding' => true,
'iconv.output_encoding' => true,
'iconv.internal_encoding' => true,
'mbstring.func_overload' => true,
'mbstring.http_input' => true,
'mbstring.http_output' => true,
'mbstring.internal_encoding' => true,
'pdo_odbc.db2_instance_name' => true,
'string.strip_tags' => true,
],

'8.0' => [
'iconv.input_encoding' => true,
'iconv.output_encoding' => true,
'iconv.internal_encoding' => true,
'mbstring.http_input' => true,
'mbstring.http_output' => true,
'mbstring.internal_encoding' => true,
],

'8.1' => [
'auto_detect_line_endings' => true,
'filter.default' => true,
'iconv.input_encoding' => true,
'iconv.output_encoding' => true,
'iconv.internal_encoding' => true,
'mbstring.http_input' => true,
'mbstring.http_output' => true,
'mbstring.internal_encoding' => true,
'oci8.old_oci_close_semantics' => true,
],

'8.2' => [
'auto_detect_line_endings' => true,
'filter.default' => true,
'iconv.input_encoding' => true,
'iconv.output_encoding' => true,
'iconv.internal_encoding' => true,
'mbstring.http_input' => true,
'mbstring.http_output' => true,
'mbstring.internal_encoding' => true,
'oci8.old_oci_close_semantics' => true,
],

'8.3' => [
'auto_detect_line_endings' => true,
'filter.default' => true,
'iconv.input_encoding' => true,
'iconv.output_encoding' => true,
'iconv.internal_encoding' => true,
'mbstring.http_input' => true,
'mbstring.http_output' => true,
'mbstring.internal_encoding' => true,
'oci8.old_oci_close_semantics' => true,
],
];

/**
* @throws Exception
*/
Expand Down Expand Up @@ -106,6 +181,10 @@ public static function getIniSettingsAsString(): string
$result = '';

foreach (ini_get_all(null, false) as $key => $value) {
if (self::isIniSettingDeprecated($key)) {
continue;
}

$result .= sprintf(
'@ini_set(%s, %s);' . "\n",
self::exportVariable($key),
Expand Down Expand Up @@ -200,4 +279,9 @@ private static function arrayOnlyContainsScalars(array $array): bool

return $result;
}

private static function isIniSettingDeprecated(string $iniSetting): bool
{
return isset(self::DEPRECATED_INI_SETTINGS[PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION][$iniSetting]);
}
}

0 comments on commit 7542687

Please sign in to comment.