diff --git a/src/Symfony/Component/VarDumper/CHANGELOG.md b/src/Symfony/Component/VarDumper/CHANGELOG.md index e47de40cc219f..569f387c7ffa4 100644 --- a/src/Symfony/Component/VarDumper/CHANGELOG.md +++ b/src/Symfony/Component/VarDumper/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * Add support for `FORCE_COLOR` environment variable * Add support for virtual properties + * Only select HtmlDumper if `Accept` header is set with non-CLI SAPI 7.1 --- diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/functions/dump_with_accept_header_html.phpt b/src/Symfony/Component/VarDumper/Tests/Dumper/functions/dump_with_accept_header_html.phpt new file mode 100644 index 0000000000000..3d71060119845 --- /dev/null +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/functions/dump_with_accept_header_html.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test dump() with "Accept: text/html" uses CLI dumper with CLI SAPI +--FILE-- + new SourceContextProvider(null, null, $fileLinkFormatter), ]; } + + private static function guessMostSuitableDumper(): DataDumperInterface + { + if (\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { + return new CliDumper(); + } + + if (str_contains($_SERVER['HTTP_ACCEPT'] ?? 'html', 'html')) { + return new HtmlDumper(); + } + + return new CliDumper(); + } }