Skip to content

Commit 04e48bd

Browse files
committed
minor symfony#22557 [VarDumper] Add iconv dependency (julienfalque)
This PR was merged into the 2.8 branch. Discussion ---------- [VarDumper] Add iconv dependency | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Alternative to symfony#20927. I still think adding `@requires extension iconv` to the related tests would be nice though: on some PHP setups the iconv extension is not available by default, those tests will fail and result in red errors when running the test suite, even when working on something unrelated. The test would still run on CI so it's fine IMO. Should I add `ext-iconv` and/or `symfony/polyfill` to `require-dev`? /cc @nicolas-grekas Commits ------- 13f1707 Add iconv extension to suggested dependencies
2 parents e9e4c79 + 13f1707 commit 04e48bd

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ protected function echoLine($line, $depth, $indentPad)
167167
*/
168168
protected function utf8Encode($s)
169169
{
170+
if (!function_exists('iconv')) {
171+
throw new \RuntimeException('Unable to convert a non-UTF-8 string to UTF-8: required function iconv() does not exist. You should install ext-iconv or symfony/polyfill-iconv.');
172+
}
170173
if (false !== $c = @iconv($this->charset, 'UTF-8', $s)) {
171174
return $c;
172175
}

src/Symfony/Component/VarDumper/composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
"symfony/polyfill-mbstring": "~1.0"
2121
},
2222
"require-dev": {
23+
"ext-iconv": "*",
2324
"twig/twig": "~1.20|~2.0"
2425
},
2526
"conflict": {
2627
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
2728
},
2829
"suggest": {
30+
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
2931
"ext-symfony_debug": ""
3032
},
3133
"autoload": {

0 commit comments

Comments
 (0)