<?php

// ===== SUPPORTED =====

define('ZLIB_ENCODING_RAW', -0x0f);
define('ZLIB_ENCODING_DEFLATE', 0x0f);
define('ZLIB_ENCODING_GZIP', 0x1f);

function gzcompress ($str ::: string, $level ::: int = -1): string;

function gzuncompress ($str ::: string): string;

// ===== UNSUPPORTED =====

/** @kphp-extern-func-info generate-stub */
function gzencode ($str ::: string, $level ::: int = -1) ::: string;
/** @kphp-extern-func-info generate-stub */
function gzdecode ($str ::: string) ::: string;
/** @kphp-extern-func-info generate-stub */
function gzdeflate ($str ::: string, $level ::: int = -1) ::: string;
/** @kphp-extern-func-info generate-stub */
function gzinflate ($str ::: string) ::: string;


/** @kphp-extern-func-info generate-stub */
function hash_hmac_algos () ::: string[];
/** @kphp-extern-func-info generate-stub */
function hash ($algo ::: string, $data ::: string, $raw_output ::: bool = false) ::: string;
/** @kphp-extern-func-info generate-stub */
function hash_hmac ($algo ::: string, $data ::: string, $key ::: string, $raw_output ::: bool = false) ::: string;
/** @kphp-extern-func-info generate-stub */
function hash_equals(string $known_string, string $user_string) ::: bool;
/** @kphp-extern-func-info generate-stub */
function md5_file ($s ::: string, $raw_output ::: bool = false) ::: string | false;
/** @kphp-extern-func-info generate-stub */
function sha1 ($s ::: string, $raw_output ::: bool = false) ::: string;

define('ZLIB_NO_FLUSH', 0);
define('ZLIB_PARTIAL_FLUSH', 1);
define('ZLIB_SYNC_FLUSH', 2);
define('ZLIB_FULL_FLUSH', 3);
define('ZLIB_FINISH', 4);
define('ZLIB_BLOCK', 5);
define('ZLIB_TREES', 6);

define('ZLIB_FILTERED', 1);
define('ZLIB_HUFFMAN_ONLY', 2);
define('ZLIB_RLE', 3);
define('ZLIB_FIXED', 4);
define('ZLIB_DEFAULT_STRATEGY', 0);

/** @kphp-generate-stub-class */
final class DeflateContext {
    private function __construct() ::: DeflateContext;
}

// todo: deflate_init php signature has type array instead mixed
/** @kphp-extern-func-info generate-stub */
function deflate_init(int $encoding, mixed $options = []) ::: ?DeflateContext;
/** @kphp-extern-func-info generate-stub */
function deflate_add(DeflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH) ::: string | false;

