{"record":{"id":"a913c192201656e8","repo":"symfony/var-dumper","slug":"theme-s-does-not-exist-in-class-s","errorCode":null,"errorMessage":"Theme \"%s\" does not exist in class \"%s\".","messagePattern":"Theme \"(.+?)\" does not exist in class \"(.+?)\"\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Dumper/HtmlDumper.php","lineNumber":98,"sourceCode":"\n    public function __construct($output = null, ?string $charset = null, int $flags = 0)\n    {\n        AbstractDumper::__construct($output, $charset, $flags);\n        $this->dumpId = 'sf-dump-'.mt_rand();\n        $this->displayOptions['fileLinkFormat'] = \\ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');\n        $this->styles = static::$themes['dark'] ?? self::$themes['dark'];\n    }\n\n    public function setStyles(array $styles): void\n    {\n        $this->headerIsDumped = false;\n        $this->styles = $styles + $this->styles;\n    }\n\n    public function setTheme(string $themeName): void\n    {\n        if (!isset(static::$themes[$themeName])) {\n            throw new \\InvalidArgumentException(\\sprintf('Theme \"%s\" does not exist in class \"%s\".', $themeName, static::class));\n        }\n\n        $this->setStyles(static::$themes[$themeName]);\n    }\n\n    /**\n     * Configures display options.\n     *\n     * @param array $displayOptions A map of display options to customize the behavior\n     */\n    public function setDisplayOptions(array $displayOptions): void\n    {\n        $this->headerIsDumped = false;\n        $this->displayOptions = $displayOptions + $this->displayOptions;\n    }\n\n    /**\n     * Sets an HTML header that will be dumped once in the output stream.","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/symfony/var-dumper/blob/e9d9cf5dcdd4b1b13b4504aaffd66ce4ddb5684e/Dumper/HtmlDumper.php#L80-L116","documentation":"HtmlDumper::setTheme() validates the theme name against static::$themes (which defines 'default' and 'dark'). An unknown name throws InvalidArgumentException instead of silently keeping the current styles.","triggerScenarios":"Calling `(new HtmlDumper())->setTheme('light')` or setTheme with any name not present in HtmlDumper::$themes; configuring a profiler/dump output with a mistyped theme option.","commonSituations":"Typos like 'dark-theme' or 'light'; assuming other themes exist; custom themes registered in a subclass but setTheme called on the base class.","solutions":["Use a built-in theme name: 'default' or 'dark'","Check available themes in HtmlDumper::$themes for your installed version","For custom themes, subclass HtmlDumper, add an entry to static::$themes, then call setTheme on the subclass"],"exampleFix":"// before\n$dumper->setTheme('light');\n// after\n$dumper->setTheme('dark');","handlingStrategy":"validation","validationCode":"$theme = $options['theme'] ?? 'default';\nif (!isset(\\Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper::$themes[$theme])) {\n    throw new \\InvalidArgumentException(sprintf('Unknown theme \"%s\"; available: %s', $theme, implode(', ', array_keys(\\Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper::$themes))));\n}","typeGuard":"function themeExists(string $theme, string $class = \\Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper::class): bool {\n    return isset($class::$themes[$theme]);\n}","tryCatchPattern":"try {\n    $dumper->setTheme($theme);\n} catch (\\InvalidArgumentException $e) {\n    $logger->warning($e->getMessage());\n    $dumper->setTheme('default');\n}","preventionTips":["Validate user/config-supplied theme names against HtmlDumper::$themes before calling setTheme","Remember only 'default' and 'dark' ship with var-dumper","For custom themes, extend HtmlDumper and register the theme in static::$themes of the subclass"],"tags":["html-dumper","theme","invalid-input"],"backgroundTag":"invalid-enum-value","analyzedSha":"e9d9cf5dcdd4b1b13b4504aaffd66ce4ddb5684e","analyzedAt":"2026-09-14T11:19:53.665Z","contentChangedAt":"2026-09-14T11:19:53.665Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}