drupflare/worker - v1.0.4
    Preparing search index...

    Variable BROTLI_FIX_PHPConst

    BROTLI_FIX_PHP: "\n// ext-brotli stand-in over the host bridge. Declared only where the extension is absent and the\n// bridge resolves. A conditional declaration binds at runtime, so this lints clean on a build that\n// HAS brotli and the branch does not run.\nif (!function_exists('brotli_compress') && function_exists('vrzno_env')) {\n\t$__cfw_brotli = vrzno_env('cfwBrotli');\n\tif ($__cfw_brotli !== null) {\n\t\t$GLOBALS['__cfw_brotli'] = $__cfw_brotli;\n\n\t\t// the values ext-brotli 0.21 declares\n\t\tif (!defined('BROTLI_GENERIC')) {\n\t\t\tdefine('BROTLI_GENERIC', 0);\n\t\t}\n\t\tif (!defined('BROTLI_TEXT')) {\n\t\t\tdefine('BROTLI_TEXT', 1);\n\t\t}\n\t\tif (!defined('BROTLI_FONT')) {\n\t\t\tdefine('BROTLI_FONT', 2);\n\t\t}\n\t\tif (!defined('BROTLI_COMPRESS_LEVEL_MIN')) {\n\t\t\tdefine('BROTLI_COMPRESS_LEVEL_MIN', 0);\n\t\t}\n\t\tif (!defined('BROTLI_COMPRESS_LEVEL_MAX')) {\n\t\t\tdefine('BROTLI_COMPRESS_LEVEL_MAX', 11);\n\t\t}\n\t\tif (!defined('BROTLI_COMPRESS_LEVEL_DEFAULT')) {\n\t\t\tdefine('BROTLI_COMPRESS_LEVEL_DEFAULT', 11);\n\t\t}\n\n\t\t/**\n\t\t * Runs one op over the bridge.\n\t\t *\n\t\t * @param string $op\n\t\t * The operation, compress or uncompress.\n\t\t * @param string $data\n\t\t * The bytes to transform.\n\t\t * @param int $level\n\t\t * A brotli quality, 0 to 11.\n\t\t * @param int $mode\n\t\t * BROTLI_GENERIC, BROTLI_TEXT or BROTLI_FONT.\n\t\t * @param string $dict\n\t\t * A preset dictionary, or an empty string for none. The host refuses one.\n\t\t *\n\t\t * @return array{ok: bool, data?: string, error?: string}\n\t\t * The decoded reply, or the reason it failed.\n\t\t */\n\t\tfunction cfw_brotli($op, $data, $level = 11, $mode = 0, $dict = ''): array\n\t\t{\n\t\t\t$fn = $GLOBALS['__cfw_brotli'];\n\t\t\t$reply = json_decode(\n\t\t\t\t$fn(\n\t\t\t\t\tjson_encode([\n\t\t\t\t\t\t'op' => $op,\n\t\t\t\t\t\t'b64' => base64_encode((string) $data),\n\t\t\t\t\t\t'level' => $level,\n\t\t\t\t\t\t'mode' => $mode,\n\t\t\t\t\t\t'dict' => base64_encode((string) $dict),\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tif (!is_array($reply) || ($reply['ok'] ?? false) !== true) {\n\t\t\t\t$why = is_array($reply)\n\t\t\t\t\t? (string) ($reply['error'] ?? 'no reason given')\n\t\t\t\t\t: 'unreadable reply';\n\t\t\t\treturn ['ok' => false, 'error' => $why];\n\t\t\t}\n\t\t\t$out = base64_decode((string) ($reply['b64'] ?? ''), true);\n\t\t\tif ($out === false) {\n\t\t\t\treturn ['ok' => false, 'error' => 'reply was not base64'];\n\t\t\t}\n\t\t\treturn ['ok' => true, 'data' => $out];\n\t\t}\n\n\t\t/**\n\t\t * Raises the diagnostic ext-brotli raises, then answers FALSE like it does.\n\t\t *\n\t\t * @param string $name\n\t\t * The PHP function that failed.\n\t\t * @param string $reason\n\t\t * What ext-brotli would have said.\n\t\t */\n\t\tfunction cfw_brotli_fail($name, $reason): false\n\t\t{\n\t\t\ttrigger_error($name . '(): ' . $reason, E_USER_WARNING);\n\t\t\treturn false;\n\t\t}\n\n\t\t/**\n\t\t * Compresses a string with brotli.\n\t\t *\n\t\t * @param string $data\n\t\t * The bytes to compress.\n\t\t * @param int $level\n\t\t * A brotli quality, 0 to 11.\n\t\t * @param int $mode\n\t\t * BROTLI_GENERIC, BROTLI_TEXT or BROTLI_FONT.\n\t\t * @param string|null $dict\n\t\t * Not supported on this host; a non-empty value is refused.\n\t\t *\n\t\t * @return string|false\n\t\t * The compressed bytes, or FALSE on failure.\n\t\t */\n\t\tfunction brotli_compress($data, $level = 11, $mode = 0, $dict = null)\n\t\t{\n\t\t\t$r = cfw_brotli('compress', $data, $level, $mode, $dict ?? '');\n\t\t\treturn $r['ok'] ? $r['data'] : cfw_brotli_fail('brotli_compress', $r['error']);\n\t\t}\n\n\t\t/**\n\t\t * Decompresses a brotli stream.\n\t\t *\n\t\t * @param string $data\n\t\t * The brotli stream.\n\t\t * @param string|null $dict\n\t\t * Not supported on this host; a non-empty value is refused.\n\t\t *\n\t\t * @return string|false\n\t\t * The decompressed bytes, or FALSE on failure.\n\t\t */\n\t\tfunction brotli_uncompress($data, $dict = null)\n\t\t{\n\t\t\t$r = cfw_brotli('uncompress', $data, 11, 0, $dict ?? '');\n\t\t\treturn $r['ok'] ? $r['data'] : cfw_brotli_fail('brotli_uncompress', $r['error']);\n\t\t}\n\t}\n}\n"