php / php/php-src

`set_error_handler` should be able to handle fatal error once

Open
#12,967 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Currently, fatal error can be handled, but it is not possible to do so using handler set by set_error_handler, but workaround using register_shutdown_function. This is not only too complex, but there is no guarantee such handler is/was registered as the first shutdown function.

An example is here: https://github.com/phpstan/phpstan-src/blob/1.10.50/src/Command/CommandHelper.php#L137-L154

This is a feature request to allow error handler to handle fatal error when php enters into shutdown before the 1st shutdown handler is executed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing set_error_handler and register_shutdown_function behavior described in the issue, and review the linked phpstan example for the current workaround. Done means a fatal error can be handled once through the error handler before the first shutdown handler runs, without relying on a separately registered shutdown function.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.