Skip to content

[VarDumper][DX] Selectively disabling control characters alternatives / allowing to copy real code #23921

@kiler129

Description

@kiler129
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no

Currently VarDumper (specifically \Symfony\Component\VarDumper\Dumper\CliDumper) replaces common control characters with their visible representation. There's however a problem with this approach - copied result is unusable without manual modification.

default_dump

I was thinking about solving the problem. For new lines solution will be bare simple - giving some control over \Symfony\Component\VarDumper\Dumper\CliDumper::$controlCharsMap, which easily let's the developer to create print like the one below:

copy_dump

This solution however is slightly hacky in my opinion, since in order to achieve such result I had to create such definition:

    protected static $controlCharsMap = array(
        "\t" => '\t',
        "\n" => "",
        "\v" => '\v',
        "\f" => '\f',
        "\r" => '\r',
        "\033" => '\e',
    );

Maybe there's a way to make just copying usable? In HTML we can offer option to copy raw string, without any enhancements like control characters replacement. For CLI there's no such way unfortunately...

Do you have any ideas how to improve DX of this functionality?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions