set_error_handler

Supported Versions: PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8
Sets a user-defined error handler function
<?php set_error_handler(?callable $callback, int $error_levels = E_ALL): ?callable
<?php         error_reporting(-1);



        set_error_handler($this->forwardsTo('handleError'));



        set_exception_handler($this->forwardsTo('handleException'));
<?php         }



        while (true) {

            $previousHandler = set_error_handler(static fn () => null);



            restore_error_handler();
<?php     protected function withDeprecationHandling()

    {

        if ($this->originalDeprecationHandler) {

            set_error_handler(tap($this->originalDeprecationHandler, fn () => $this->originalDeprecationHandler = null));

        }



        return $this;
<?php     protected function withoutDeprecationHandling()

    {

        if ($this->originalDeprecationHandler == null) {

            $this->originalDeprecationHandler = set_error_handler(function ($level, $message, $file = '', $line = 0) {

                if (in_array($level, [E_DEPRECATED, E_USER_DEPRECATED]) || (error_reporting() & $level)) {

                    throw new ErrorException($message, 0, $level, $file, $line);

                }

            });

        }



        return $this;
<?php     {

        parent::setUp();



        set_error_handler(function () {

            $this->deprecationsFound = true;

        });

    }



    public function testWithDeprecationHandling()