protected function populateErrorData(\Throwable $e, array $data): \Throwable
    {
        static $cache = [];
        static $props = [
            'code',
            'message',
            'file',
            'line'
        ];
        
        $type = ($e instanceof \Error) ? \Error::class : \Exception::class;
        
        if (!isset($cache[$type])) {
            $cache[$type] = [];
            
            foreach ($props as $k) {
                $ref = new \ReflectionProperty($type, $k);
                $ref->setAccessible(true);
                
                $cache[$type][$k] = $ref;
            }
        }
        
        foreach ($props as $k) {
            if (isset($data[$k])) {
                $cache[$type][$k]->setValue($e, $data[$k]);
            }
        }
        
        return $e;
    }
protected function populateErrorData(\Throwable $e, array $data): \Throwable
    {
        static $cache = [];
        static $props = [
            'code',
            'message',
            'file',
            'line'
        ];
        
        $type = ($e instanceof \Error) ? \Error::class : \Exception::class;
        
        if (!isset($cache[$type])) {
            $cache[$type] = [];
            
            foreach ($props as $k) {
                $ref = new \ReflectionProperty($type, $k);
                $ref->setAccessible(true);
                
                $cache[$type][$k] = $ref;
            }
        }
        
        foreach ($props as $k) {
            if (isset($data[$k])) {
                $cache[$type][$k]->setValue($e, $data[$k]);
            }
        }
        
        return $e;
    }
protected function populateErrorData ( \ Throwable $ e , array $ data ) : \ Throwable { static $ cache = [ ] ; static $ props = [ 'code' , 'message' , 'file' , 'line' ] ; $ type = ( $ e instanceof \ Error ) ? \ Error :: class : \ Exception :: class ; if ( ! isset ( $ cache [ $ type ] ) ) { $ cache [ $ type ] = [ ] ; foreach ( $ props as $ k ) { $ ref = new \ ReflectionProperty ( $ type , $ k ) ; $ ref -> setAccessible ( true ) ; $ cache [ $ type ] [ $ k ] = $ ref ; } } foreach ( $ props as $ k ) { if ( isset ( $ data [ $ k ] ) ) { $ cache [ $ type ] [ $ k ] -> setValue ( $ e , $ data [ $ k ] ) ; } } return $ e ; }
Populate properties of the given error from unserialized data.

@param \Throwable $e The error to be enriched with transferred data.
@param array $data Received error data.
Populate properties of the given error from unserialized data .