Skip to content

[12.x] Display closures and standalone functions correctly in exception trace#58879

Merged
taylorotwell merged 2 commits into
12.xfrom
exception-renderer-standalone-function-display
Feb 17, 2026
Merged

[12.x] Display closures and standalone functions correctly in exception trace#58879
taylorotwell merged 2 commits into
12.xfrom
exception-renderer-standalone-function-display

Conversation

@avosalmon

@avosalmon avosalmon commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

The exception renderer's trace frames now use each frame's own trace data (class, type, function) instead of stitching together the classmap class with the previous frame's callable. This fixes two issues:

  • Standalone functions like array_map were concatenated directly onto the class name (e.g. UserControllerarray_map()) due to the missing operator
  • Closures were never shown — the closure info lived on a frame that had no file and was filtered out

Before

CleanShot 2026-02-17 at 14 39 31@2x

After

CleanShot 2026-02-17 at 14 38 49@2x

Comment on lines +123 to +128
if (count($trace) > 1 && empty($trace[0]['class']) && empty($trace[0]['function'])) {
$trace[0]['class'] = $trace[1]['class'] ?? '';
$trace[0]['type'] = $trace[1]['type'] ?? '';
$trace[0]['function'] = $trace[1]['function'] ?? '';
$trace[0]['args'] = $trace[1]['args'] ?? [];
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The throw-point frame added by FlattenException (which has file/line but no class/function) is now enriched with the executing function's data from the next trace entry, so closures like UserController->{closure:UserController::show():19}() display correctly.

@avosalmon avosalmon marked this pull request as draft February 17, 2026 05:46
@avosalmon avosalmon marked this pull request as ready for review February 17, 2026 06:42
@taylorotwell taylorotwell merged commit fa95603 into 12.x Feb 17, 2026
72 checks passed
@taylorotwell taylorotwell deleted the exception-renderer-standalone-function-display branch February 17, 2026 15:55
DarkGhostHunter pushed a commit to DarkGhostHunter/laravel-framework that referenced this pull request Feb 22, 2026
…on trace (laravel#58879)

* Display closures and standalone functions correctly in exception trace

* Fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants