@@ -23,29 +23,49 @@ class HtmlDumper extends CliDumper
23
23
{
24
24
public static $ defaultOutput = 'php://output ' ;
25
25
26
+ protected static $ themes = array (
27
+ 'dark ' => array (
28
+ 'default ' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all ' ,
29
+ 'num ' => 'font-weight:bold; color:#1299DA ' ,
30
+ 'const ' => 'font-weight:bold ' ,
31
+ 'str ' => 'font-weight:bold; color:#56DB3A ' ,
32
+ 'note ' => 'color:#1299DA ' ,
33
+ 'ref ' => 'color:#A0A0A0 ' ,
34
+ 'public ' => 'color:#FFFFFF ' ,
35
+ 'protected ' => 'color:#FFFFFF ' ,
36
+ 'private ' => 'color:#FFFFFF ' ,
37
+ 'meta ' => 'color:#B729D9 ' ,
38
+ 'key ' => 'color:#56DB3A ' ,
39
+ 'index ' => 'color:#1299DA ' ,
40
+ 'ellipsis ' => 'color:#FF8400 ' ,
41
+ 'ns ' => 'user-select:none; ' ,
42
+ ),
43
+ 'light ' => array (
44
+ 'default ' => 'background:none; color:#CC7832; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all ' ,
45
+ 'num ' => 'font-weight:bold; color:#1299DA ' ,
46
+ 'const ' => 'font-weight:bold ' ,
47
+ 'str ' => 'font-weight:bold; color:#629755; ' ,
48
+ 'note ' => 'color:#6897BB ' ,
49
+ 'ref ' => 'color:#6E6E6E ' ,
50
+ 'public ' => 'color:#262626 ' ,
51
+ 'protected ' => 'color:#262626 ' ,
52
+ 'private ' => 'color:#262626 ' ,
53
+ 'meta ' => 'color:#B729D9 ' ,
54
+ 'key ' => 'color:#789339 ' ,
55
+ 'index ' => 'color:#1299DA ' ,
56
+ 'ellipsis ' => 'color:#CC7832 ' ,
57
+ 'ns ' => 'user-select:none; ' ,
58
+ ),
59
+ );
60
+
26
61
protected $ dumpHeader ;
27
62
protected $ dumpPrefix = '<pre class=sf-dump id=%s data-indent-pad="%s"> ' ;
28
63
protected $ dumpSuffix = '</pre><script>Sfdump(%s)</script> ' ;
29
64
protected $ dumpId = 'sf-dump ' ;
30
65
protected $ colors = true ;
31
66
protected $ headerIsDumped = false ;
32
67
protected $ lastDepth = -1 ;
33
- protected $ styles = array (
34
- 'default ' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all ' ,
35
- 'num ' => 'font-weight:bold; color:#1299DA ' ,
36
- 'const ' => 'font-weight:bold ' ,
37
- 'str ' => 'font-weight:bold; color:#56DB3A ' ,
38
- 'note ' => 'color:#1299DA ' ,
39
- 'ref ' => 'color:#A0A0A0 ' ,
40
- 'public ' => 'color:#FFFFFF ' ,
41
- 'protected ' => 'color:#FFFFFF ' ,
42
- 'private ' => 'color:#FFFFFF ' ,
43
- 'meta ' => 'color:#B729D9 ' ,
44
- 'key ' => 'color:#56DB3A ' ,
45
- 'index ' => 'color:#1299DA ' ,
46
- 'ellipsis ' => 'color:#FF8400 ' ,
47
- 'ns ' => 'user-select:none; ' ,
48
- );
68
+ protected $ styles ;
49
69
50
70
private $ displayOptions = array (
51
71
'maxDepth ' => 1 ,
@@ -62,6 +82,7 @@ public function __construct($output = null, string $charset = null, int $flags =
62
82
AbstractDumper::__construct ($ output , $ charset , $ flags );
63
83
$ this ->dumpId = 'sf-dump- ' .mt_rand ();
64
84
$ this ->displayOptions ['fileLinkFormat ' ] = ini_get ('xdebug.file_link_format ' ) ?: get_cfg_var ('xdebug.file_link_format ' );
85
+ $ this ->styles = static ::$ themes ['dark ' ] ?? self ::$ themes ['dark ' ];
65
86
}
66
87
67
88
/**
@@ -73,6 +94,15 @@ public function setStyles(array $styles)
73
94
$ this ->styles = $ styles + $ this ->styles ;
74
95
}
75
96
97
+ public function setTheme (string $ themeName )
98
+ {
99
+ if (!isset (static ::$ themes [$ themeName ])) {
100
+ throw new \InvalidArgumentException (sprintf ('Theme "%s" does not exist in class "%s". ' , $ themeName , static ::class));
101
+ }
102
+
103
+ $ this ->setStyles (static ::$ themes [$ themeName ]);
104
+ }
105
+
76
106
/**
77
107
* Configures display options.
78
108
*
0 commit comments