P
P
posters2020-08-28 13:49:39
symfony
posters, 2020-08-28 13:49:39

How to properly change theme in symfony var-dumper?

I use symfony var-dumper separately from symfony. Decided to change the theme to light. To do this, I made the following function in my code:

function dump($data) {
    $dumper = new \Symfony\Component\VarDumper\Dumper\HtmlDumper();
    $dumper->setTheme('light');
    $dumper->dump($data);
}

But it doesn't work the way it should. I am getting an error.
Fatal error: Uncaught TypeError: Argument 1 passed to Symfony\Component\VarDumper\Dumper\HtmlDumper::dump() must be an instance of Symfony\Component\VarDumper\Cloner\Data, instance of PhpOffice\PhpWord\Element\Section given, called in C:\laragon\www\word\index.php on line 12 and defined in C:\laragon\www\word\vendor\symfony\var-dumper\Dumper\HtmlDumper.php:142 Stack trace: #0 C:\laragon\www\word\index.php(12): Symfony\Component\VarDumper\Dumper\HtmlDumper->dump(Object(PhpOffice\PhpWord\Element\Section)) #1 C:\laragon\www\word\index.php(117): dump(Object(PhpOffice\PhpWord\Element\Section)) #2 {main} thrown in C:\laragon\www\word\vendor\symfony\var-dumper\Dumper\HtmlDumper.php on line 142

How to change the theme?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Latukhin, 2020-08-28
@posters

What do you have in $data ?
This class should be: Symfony\Component\VarDumper\Cloner\Data;
you also write in an error that you are passing the wrong class

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question