public static function append($stream, $callback, $read_write = STREAM_FILTER_ALL)
    {
        $ret = @\stream_filter_append($stream, self::register(), $read_write, $callback);
        if ($ret === false) {
            $error = \error_get_last() + ['message' => ''];
            throw new \RuntimeException('Unable to append filter: ' . $error['message']);
        }

        return $ret;
    }