@@ -105,12 +105,19 @@ final class HtmlRenderer implements ThrowableRendererInterface
105105 private ?array $ vendorPaths = null ;
106106
107107 /**
108- * @param array $settings Settings can have the following keys:
108+ * @param array $settings (deprecated) Settings can have the following keys:
109109 * - template: string, full path of the template file for rendering exceptions without call stack information.
110110 * - verboseTemplate: string, full path of the template file for rendering exceptions with call stack information.
111111 * - maxSourceLines: int, maximum number of source code lines to be displayed. Defaults to 19.
112112 * - maxTraceLines: int, maximum number of trace source code lines to be displayed. Defaults to 13.
113- * - traceHeaderLine: string, trace header line with placeholders to be be substituted. Defaults to null.
113+ * - traceHeaderLine: string, trace header line with placeholders to be substituted. Defaults to null.
114+ * @param string|null $template The full path of the template file for rendering exceptions without call stack
115+ * information.
116+ * @param string|null $verboseTemplate The full path of the template file for rendering exceptions with call stack
117+ * information.
118+ * @param int|null $maxSourceLines The maximum number of source code lines to be displayed. Defaults to 19.
119+ * @param int|null $maxTraceLines The maximum number of trace source code lines to be displayed. Defaults to 13.
120+ * @param string|null $traceHeaderLine The trace header line with placeholders to be substituted. Defaults to null.
114121 *
115122 * @psalm-param array{
116123 * template?: string,
@@ -120,17 +127,33 @@ final class HtmlRenderer implements ThrowableRendererInterface
120127 * traceHeaderLine?: string,
121128 * } $settings
122129 */
123- public function __construct (array $ settings = [])
124- {
130+ public function __construct (
131+ array $ settings = [],
132+ ?string $ template = null ,
133+ ?string $ verboseTemplate = null ,
134+ ?int $ maxSourceLines = null ,
135+ ?int $ maxTraceLines = null ,
136+ ?string $ traceHeaderLine = null ,
137+ ) {
125138 $ this ->markdownParser = new GithubMarkdown ();
126139 $ this ->markdownParser ->html5 = true ;
127140
128141 $ this ->defaultTemplatePath = dirname (__DIR__ , 2 ) . '/templates ' ;
129- $ this ->template = $ settings ['template ' ] ?? $ this ->defaultTemplatePath . '/production.php ' ;
130- $ this ->verboseTemplate = $ settings ['verboseTemplate ' ] ?? $ this ->defaultTemplatePath . '/development.php ' ;
131- $ this ->maxSourceLines = $ settings ['maxSourceLines ' ] ?? 19 ;
132- $ this ->maxTraceLines = $ settings ['maxTraceLines ' ] ?? 13 ;
133- $ this ->traceHeaderLine = $ settings ['traceHeaderLine ' ] ?? null ;
142+ $ this ->template = $ template
143+ ?? $ settings ['template ' ]
144+ ?? $ this ->defaultTemplatePath . '/production.php ' ;
145+ $ this ->verboseTemplate = $ verboseTemplate
146+ ?? $ settings ['verboseTemplate ' ]
147+ ?? $ this ->defaultTemplatePath . '/development.php ' ;
148+ $ this ->maxSourceLines = $ maxSourceLines
149+ ?? $ settings ['maxSourceLines ' ]
150+ ?? 19 ;
151+ $ this ->maxTraceLines = $ maxTraceLines
152+ ?? $ settings ['maxTraceLines ' ]
153+ ?? 13 ;
154+ $ this ->traceHeaderLine = $ traceHeaderLine
155+ ?? $ settings ['traceHeaderLine ' ]
156+ ?? null ;
134157 }
135158
136159 public function render (Throwable $ t , ServerRequestInterface $ request = null ): ErrorData
0 commit comments