-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[VarDumper] Allow to use a light theme out of the box #27261 10000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,29 +23,49 @@ class HtmlDumper extends CliDumper | |
{ | ||
public static $defaultOutput = 'php://output'; | ||
|
||
protected static $themes = array( | ||
'dark' => array( | ||
'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', | ||
'num' => 'font-weight:bold; color:#1299DA', | ||
'const' => 'font-weight:bold', | ||
'str' => 'font-weight:bold; color:#56DB3A', | ||
'note' => 'color:#1299DA', | ||
'ref' => 'color:#A0A0A0', | ||
'public' => 'color:#FFFFFF', | ||
'protected' => 'color:#FFFFFF', | ||
'private' => 'color:#FFFFFF', | ||
'meta' => 'color:#B729D9', | ||
'key' => 'color:#56DB3A', | ||
'index' => 'color:#1299DA', | ||
'ellipsis' => 'color:#FF8400', | ||
'ns' => 'user-select:none;', | ||
), | ||
'light' => array( | ||
'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', | ||
'num' => 'font-weight:bold; color:#1299DA', | ||
'const' => 'font-weight:bold', | ||
'str' => 'font-weight:bold; color:#629755;', | ||
'note' => 'color:#6897BB', | ||
'ref' => 'color:#6E6E6E', | ||
'public' => 'color:#262626', | ||
'protected' => 'color:#262626', | ||
'private' => 'color:#262626', | ||
'meta' => 'color:#B729D9', | ||
'key' => 'color:#789339', | ||
'index' => 'color:#1299DA', | ||
'ellipsis' => 'color:#CC7832', | ||
'ns' => 'user-select:none;', | ||
), | ||
); | ||
|
||
protected $dumpHeader; | ||
protected $dumpPrefix = '<pre class=sf-dump id=%s data-indent-pad="%s">'; | ||
protected $dumpSuffix = '</pre><script>Sfdump(%s)</script>'; | ||
protected $dumpId = 'sf-dump'; | ||
protected $colors = true; | ||
protected $headerIsDumped = false; | ||
protected $lastDepth = -1; | ||
protected $styles = array( | ||
'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', | ||
'num' => 'font-weight:bold; color:#1299DA', | ||
'const' => 'font-weight:bold', | ||
'str' => 'font-weight:bold; color:#56DB3A', | ||
'note' => 'color:#1299DA', | ||
'ref' => 'color:#A0A0A0', | ||
'public' => 'color:#FFFFFF', | ||
'protected' => 'color:#FFFFFF', | ||
'private' => 'color:#FFFFFF', | ||
'meta' => 'color:#B729D9', | ||
'key' => 'color:#56DB3A', | ||
'index' => 'color:#1299DA', | ||
'ellipsis' => 'color:#FF8400', | ||
'ns' => 'user-select:none;', | ||
); | ||
protected $styles; | ||
|
||
private $displayOptions = array( | ||
'maxDepth' => 1, | ||
|
@@ -62,6 +82,7 @@ public function __construct($output = null, string $charset = null, int $flags = | |
AbstractDumper::__construct($output, $charset, $flags); | ||
$this->dumpId = 'sf-dump-'.mt_rand(); | ||
$this->displayOptions['fileLinkFormat'] = ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); | ||
$this->styles = static::$themes['dark'] ?? self::$themes['dark']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will break the CliDumper, which was overriding the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
} | ||
|
||
/** | ||
|
@@ -73,6 +94,15 @@ public function setStyles(array $styles) | |
$this->styles = $styles + $this->styles; | ||
} | ||
|
||
public function setTheme(string $themeName) | ||
{ | ||
if (!isset(static::$themes[$themeName])) { | ||
throw new \InvalidArgumentException(sprintf('Theme "%s" does not exist in class "%s".', $themeName, static::class)); | ||
} | ||
|
||
$this->setStyles(static::$themes[$themeName]); | ||
} | ||
|
||
/** | ||
* Configures display options. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tend to believe a public
registerTheme($name, $styles, $extends = 'light')
is more useful then static overriding =/edit: or declare on CliDumper along with setTheme, enabling the feat. there as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we want to allow people to register new themes.