1414
1515/**
1616 * `ErrorException` represents a PHP error.
17+ *
18+ * @psalm-type DebugBacktraceType = list<array{args?:list<mixed>,class?:class-string,file?:string,function:string,line?:int,object?:object,type?:string}>
1719 */
1820class ErrorException extends \ErrorException implements FriendlyExceptionInterface
1921{
@@ -35,14 +37,11 @@ class ErrorException extends \ErrorException implements FriendlyExceptionInterfa
3537 E_USER_DEPRECATED => 'PHP User Deprecated Warning ' ,
3638 ];
3739
38- public function __construct (
39- string $ message = '' ,
40- int $ code = 0 ,
41- int $ severity = 1 ,
42- string $ filename = __FILE__ ,
43- int $ line = __LINE__ ,
44- Exception $ previous = null
45- ) {
40+ /**
41+ * @psalm-param DebugBacktraceType $backtrace
42+ */
43+ public function __construct (string $ message = '' , int $ code = 0 , int $ severity = 1 , string $ filename = __FILE__ , int $ line = __LINE__ , Exception $ previous = null , private array $ backtrace = [])
44+ {
4645 parent ::__construct ($ message , $ code , $ severity , $ filename , $ line , $ previous );
4746 $ this ->addXDebugTraceToFatalIfAvailable ();
4847 }
@@ -76,6 +75,14 @@ public function getSolution(): ?string
7675 return null ;
7776 }
7877
78+ /**
79+ * @psalm-return DebugBacktraceType
80+ */
81+ public function getBacktrace (): array
82+ {
83+ return $ this ->backtrace ;
84+ }
85+
7986 /**
8087 * Fatal errors normally do not provide any trace making it harder to debug. In case XDebug is installed, we
8188 * can get a trace using `xdebug_get_function_stack()`.
0 commit comments