Skip to content

Commit 2faa295

Browse files
janedbalondrejmirtes
authored andcommitted
Add the PHP 8.5 trace key to error_get_last()
PHP 8.5 adds the `fatal_error_backtraces` INI setting, which is enabled by default. PHP then collects a backtrace for fatal errors and `error_get_last()` returns it under the `trace` key. The key is only present for fatal errors, and only in code that runs after shutdown, so it is optional. The frame shape matches the one `debug_backtrace()` already uses. Co-Authored-By: Claude Code
1 parent 4760394 commit 2faa295

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎resources/functionMap_php85delta.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
return [
1717
'new' => [
1818
'chr' => ['non-empty-string', 'ascii'=>'int<0,255>'],
19+
'error_get_last' => ['?array{type:int,message:string,file:string,line:int,trace?:list<array{function:string,line?:int,file?:string,class?:class-string,type?:\'::\'|\'->\',args?:list<mixed>,object?:object}>}'],
1920
'session_get_cookie_params' => ['array{lifetime:0|positive-int,path:non-falsy-string,domain:string,secure:bool,httponly:bool,samesite:\'None\'|\'Lax\'|\'Strict\'|\'none\'|\'lax\'|\'strict\',partitioned:bool}'],
2021
'session_set_cookie_params\'1' => ['bool', 'options'=>'array{lifetime?:int,path?:string,domain?:string,secure?:bool,httponly?:bool,samesite?:\'None\'|\'Lax\'|\'Strict\'|\'none\'|\'lax\'|\'strict\',partitioned?:bool}'],
2122
'setcookie\'1' => ['bool', 'name'=>'string', 'value='=>'string', 'options='=>'array{ expires?:int, path?:string, domain?:string, secure?:bool, httponly?:bool, samesite?:\'None\'|\'Lax\'|\'Strict\'|\'none\'|\'lax\'|\'strict\', partitioned?:bool}'],
@@ -24,6 +25,7 @@
2425
],
2526
'old' => [
2627
'chr' => ['non-empty-string', 'ascii'=>'int'],
28+
'error_get_last' => ['?array{type:int,message:string,file:string,line:int}'],
2729
'session_get_cookie_params' => ['array{lifetime:0|positive-int,path:non-falsy-string,domain:string,secure:bool,httponly:bool,samesite:\'None\'|\'Lax\'|\'Strict\'|\'none\'|\'lax\'|\'strict\'}'],
2830
'session_set_cookie_params\'1' => ['bool', 'options'=>'array{lifetime?:int,path?:string,domain?:string,secure?:bool,httponly?:bool,samesite?:\'None\'|\'Lax\'|\'Strict\'|\'none\'|\'lax\'|\'strict\'}'],
2931
'setcookie\'1' => ['bool', 'name'=>'string', 'value='=>'string', 'options='=>'array{ expires?:int, path?:string, domain?:string, secure?:bool, httponly?:bool, samesite?:\'None\'|\'Lax\'|\'Strict\'|\'none\'|\'lax\'|\'strict\'}'],
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php // lint >= 8.5
2+
3+
namespace ErrorGetLastPhp85;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
function test(): void
8+
{
9+
assertType("array{type: int, message: string, file: string, line: int, trace?: list<array{function: string, line?: int, file?: string, class?: class-string, type?: '->'|'::', args?: list<mixed>, object?: object}>}|null", error_get_last());
10+
}

0 commit comments

Comments
 (0)