Skip to content

Commit 2cdbe09

Browse files
vjiksamdark
andauthored
Make all parameters of ErrorException constructor required (#170)
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
1 parent ad8b02a commit 2cdbe09

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Enh #163: Explicitly import classes, functions, and constants in "use" section (@mspirkov)
88
- Bug #164: Fix missing items in stack trace HTML output when handling a PHP error (@vjik)
99
- Bug #166: Fix broken link to error handling guide (@vjik)
10+
- Chg #170: Make all parameters of `ErrorException` constructor required (@vjik)
1011
- New #171: Add `$traceFileMap` parameter to `HtmlRenderer` for mapping file paths in trace links (@WarLikeLaux)
1112

1213
## 4.3.2 January 09, 2026

src/Exception/ErrorException.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,15 @@ class ErrorException extends \ErrorException implements FriendlyExceptionInterfa
5656
];
5757

5858
/** @psalm-param DebugBacktraceType $backtrace */
59-
public function __construct(string $message = '', int $code = 0, int $severity = 1, string $filename = __FILE__, int $line = __LINE__, ?Exception $previous = null, private readonly array $backtrace = [])
60-
{
59+
public function __construct(
60+
string $message,
61+
int $code,
62+
int $severity,
63+
string $filename,
64+
int $line,
65+
?Exception $previous,
66+
private readonly array $backtrace,
67+
) {
6168
parent::__construct($message, $code, $severity, $filename, $line, $previous);
6269
$this->addXDebugTraceToFatalIfAvailable();
6370
}

tests/Renderer/HtmlRendererTest.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,15 @@ public function testRenderCallStackWithErrorException(): void
410410
$renderer = new HtmlRenderer();
411411

412412
$result = $renderer->renderCallStack(
413-
new ErrorException('test-message'),
413+
new ErrorException(
414+
'test-message',
415+
0,
416+
0,
417+
__FILE__,
418+
__LINE__,
419+
null,
420+
[],
421+
),
414422
TestHelper::generateTrace([true, true, false, true]),
415423
);
416424

@@ -442,8 +450,18 @@ public function testRenderCurlForFailRequest(): void
442450

443451
public function testGetThrowableName(): void
444452
{
453+
$exception = new ErrorException(
454+
'test-message',
455+
0,
456+
0,
457+
__FILE__,
458+
__LINE__,
459+
null,
460+
[],
461+
);
462+
445463
$renderer = new HtmlRenderer();
446-
$name = $renderer->getThrowableName(new ErrorException());
464+
$name = $renderer->getThrowableName($exception);
447465

448466
$this->assertSame('Error (' . ErrorException::class . ')', $name);
449467
}

0 commit comments

Comments
 (0)