(default), * ZLIB_FULL_FLUSH, ZLIB_FINISH. * Normally you will want to set ZLIB_NO_FLUSH to * maximize compression, and ZLIB_FINISH to terminate * with the last chunk of data. See the zlib manual for a * detailed description of these constants. * @return string Returns a chunk of uncompressed data. * @throws ZlibException * */ function inflate_add($context, string $encoded_data, int $flush_mode = ZLIB_SYNC_FLUSH): string { error_clear_last(); $result = \inflate_add($context, $encoded_data, $flush_mode); if ($result === false) { throw ZlibException::createFromPhpError(); } return $result; } /** * Initialize an incremental inflate context with the specified * encoding. * * @param int $encoding One of the ZLIB_ENCODING_* constants. * @param array $options An associative array which may contain the following elements: * * * level * * * The compression level in range -1..9; defaults to -1. * * * * * memory * * * The compression memory level in range 1..9; defaults to 8. * * * * * window * * * The zlib window size (logarithmic) in range 8..15; defaults to 15. * * * * * strategy * * * One of ZLIB_FILTERED, * ZLIB_HUFFMAN_ONLY, ZLIB_RLE, * ZLIB_FIXED or * ZLIB_DEFAULT_STRATEGY (the default). * * * * * dictionary * * * A string or an array of strings * of the preset dictionary (default: no preset dictionary). * * * * * * The compression level in range -1..9; defaults to -1. * * The compression memory level in range 1..9; defaults to 8. * * The zlib window size (logarithmic) in range 8..15; defaults to 15. * * One of ZLIB_FILTERED, * ZLIB_HUFFMAN_ONLY, ZLIB_RLE, * ZLIB_FIXED or * ZLIB_DEFAULT_STRATEGY (the default). * * A string or an array of strings * of the preset dictionary (default: no preset dictionary). * @return resource Returns an inflate context resource (zlib.inflate) on * success. * @throws ZlibException * */ function inflate_init(int $encoding, array $options = null) { error_clear_last(); $result = \inflate_init($encoding, $options); if ($result === false) { throw ZlibException::createFromPhpError(); } return $result; } /** * Reads a file, decompresses it and writes it to standard output. * * readgzfile can be used to read a file which is not in * gzip format; in this case readgzfile will directly * read from the file without decompression. * * @param string $filename The file name. This file will be opened from the filesystem and its * contents written to standard output. * @param int $use_include_path You can set this optional parameter to 1, if you * want to search for the file in the include_path too. * @return int Returns the number of (uncompressed) bytes read from the file on success * @throws ZlibException * */ function readgzfile(string $filename, int $use_include_path = 0): int { error_clear_last(); $result = \readgzfile($filename, $use_include_path); if ($result === false) { throw ZlibException::createFromPhpError(); } return $result; } /** * Uncompress any raw/gzip/zlib encoded data. * * @param string $data * @param int $max_decoded_len * @return string Returns the uncompressed data. * @throws ZlibException * */ function zlib_decode(string $data, int $max_decoded_len = null): string { error_clear_last(); if ($max_decoded_len !== null) { $result = \zlib_decode($data, $max_decoded_len); } else { $result = \zlib_decode($data); } if ($result === false) { throw ZlibException::createFromPhpError(); } return $result; }