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     public function cloneVar($var, int $filter = 0)

    {

        $this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) {

            if (\E_RECOVERABLE_ERROR === $type || \E_USER_ERROR === $type) {


                throw new \ErrorException($msg, 0, $type, $file, $line);

            }



            if ($this->prevErrorHandler) {

                return ($this->prevErrorHandler)($type, $msg, $file, $line, $context);

            }



            return false;

        });

        $this->filter = $filter;



        if ($gc = gc_enabled()) {
<?php         $context = array_filter($context);

        $encodedPayload = base64_encode(serialize([$data, $context]))."\n";



        set_error_handler([self::class, 'nullErrorHandler']);

        try {

            if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) {

                return true;
<?php     private function createSocket()

    {

        set_error_handler([self::class, 'nullErrorHandler']);

        try {

            return stream_socket_client($this->host, $errno, $errstr, 3, \STREAM_CLIENT_CONNECT | \STREAM_CLIENT_ASYNC_CONNECT);

        } finally {