src/site/php/zstd fix.php

Constants

ZSTD_COMPRESS_LEVEL_MIN

ZSTD_COMPRESS_LEVEL_MIN = 1

ZSTD_COMPRESS_LEVEL_MAX

ZSTD_COMPRESS_LEVEL_MAX = 22

ZSTD_COMPRESS_LEVEL_DEFAULT

ZSTD_COMPRESS_LEVEL_DEFAULT = 3

Functions

cfw_zstd()

cfw_zstd(string  $op, string  $data, int  $level = 3, string  $dict = '') : array{ok: bool, data?: string, error?: string}

Runs one op over the bridge.

Parameters

string $op

The operation, compress or uncompress.

string $data

The bytes to transform.

int $level

A zstd level, 1 to 22 (or zero and below).

string $dict

A preset dictionary, or an empty string for none.

Returns

array{ok: bool, data?: string, error?: string} —

The decoded reply, or the reason it failed.

cfw_zstd_fail()

cfw_zstd_fail(string  $name, string  $reason) : false

Raises the diagnostic ext-zstd raises, then answers FALSE like it does.

Parameters

string $name

The PHP function that failed.

string $reason

What ext-zstd would have said.

Returns

false —

zstd_compress()

zstd_compress(string  $data, int  $level = 3, string|null  $dict = null) : string|false

Compresses a string with zstd.

Parameters

string $data

The bytes to compress.

int $level

A zstd level, 1 to 22 (or zero and below).

string|null $dict

A preset dictionary, or NULL for none.

Returns

string|false —

The compressed bytes, or FALSE on failure.

zstd_uncompress()

zstd_uncompress(string  $data, string|null  $dict = null) : string|false

Decompresses a zstd frame.

Parameters

string $data

The zstd frame.

string|null $dict

The dictionary the frame was compressed with, or NULL for none.

Returns

string|false —

The decompressed bytes, or FALSE on failure.

zstd_decompress()

zstd_decompress(string  $data, string|null  $dict = null) : string|false

The alias ext-zstd documents beside zstd_uncompress().

Parameters

string $data

The zstd frame.

string|null $dict

The dictionary the frame was compressed with, or NULL for none.

Returns

string|false —

The decompressed bytes, or FALSE on failure.

zstd_compress_dict()

zstd_compress_dict(string  $data, string  $dict, int  $level = 3) : string|false

Compresses a string with zstd and a required dictionary.

Parameters

string $data

The bytes to compress.

string $dict

The dictionary; required.

int $level

A zstd level, 1 to 22 (or zero and below).

Returns

string|false —

The compressed bytes, or FALSE on failure.

zstd_uncompress_dict()

zstd_uncompress_dict(string  $data, string  $dict) : string|false

Decompresses a zstd frame with a required dictionary.

Parameters

string $data

The zstd frame.

string $dict

The dictionary the frame was compressed with; required.

Returns

string|false —

The decompressed bytes, or FALSE on failure.