Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
  • Loading branch information
janedbal committed Sep 17, 2026
commit 397bf12c0f4b8a3ea4cb9b7a7d61d3235998650d
2 changes: 2 additions & 0 deletions resources/functionMap_php85delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
return [
'new' => [
'chr' => ['non-empty-string', 'ascii'=>'int<0,255>'],
'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}>}'],
'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}'],
'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}'],
'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}'],
Expand All @@ -24,6 +25,7 @@
],
'old' => [
'chr' => ['non-empty-string', 'ascii'=>'int'],
'error_get_last' => ['?array{type:int,message:string,file:string,line:int}'],
'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\'}'],
'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\'}'],
'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\'}'],
Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Analyser/nsrt/error-get-last-php85.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php // lint >= 8.5

namespace ErrorGetLastPhp85;

use function PHPStan\Testing\assertType;

function test(): void
{
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());
}
Loading