<?php

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

define('PREG_NO_ERROR', 0);
define('PREG_INTERNAL_ERROR', 1);
define('PREG_BACKTRACK_LIMIT_ERROR', 2);
define('PREG_RECURSION_LIMIT_ERROR', 3);
define('PREG_BAD_UTF8_ERROR', 4);
define('PREG_BAD_UTF8_OFFSET_ERROR', 5);

define('PREG_PATTERN_ORDER', 1);
define('PREG_SET_ORDER', 2);
define('PREG_OFFSET_CAPTURE', 4);
define('PREG_SPLIT_NO_EMPTY', 8);
define('PREG_SPLIT_DELIM_CAPTURE', 16);
define('PREG_SPLIT_OFFSET_CAPTURE', 32);
define('PREG_UNMATCHED_AS_NULL', 64);

function preg_match ($regex ::: string, $subject ::: string, &$matches ::: mixed = TODO, $flags ::: int = 0, $offset ::: int = 0) ::: int | false;

function preg_match_all ($regex ::: string, $subject ::: string, &$matches ::: mixed = TODO, $flags ::: int = 0, $offset ::: int = 0) ::: int | false;

function preg_replace ($regex ::: string | array, $replace_val ::: string | array, $subject ::: string | array, $limit ::: int = -1, &$replace_count ::: int = TODO) ::: string | ^3 | false | null;

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


function preg_replace_callback ($regex ::: regexp, callable(string[] $x):string $callback, $subject, $limit ::: int = -1, &$replace_count ::: int = TODO) ::: ^3|string|null;

/** @kphp-extern-func-info generate-stub */
function preg_quote ($str ::: string, $delimiter ::: string = '') ::: string;

/** @kphp-extern-func-info generate-stub */
function preg_last_error() ::: int;

function preg_split ($pattern ::: regexp, $subject ::: string, $limit ::: int = -1, $flags ::: int = 0) ::: mixed[] | false;



