<?php

/** @kphp-generate-stub-class */
interface Memcache {
    public function get (string|string[] $key) ::: mixed;
    public function delete (string $key) ::: bool;
    public function add (string $key, mixed $value, int $flags = 0, int $expire = 0) ::: bool;
    public function set (string $key, mixed $value, int $flags = 0, int $expire = 0) ::: bool;
    public function replace (string $key, mixed $value, int $flags = 0, int $expire = 0) ::: bool;
    public function decrement (string $key, int $v = 1) ::: mixed;
    public function increment (string $key, int $v = 1) ::: mixed;
    public function getVersion () ::: mixed;

    // this two functions shouldn't be there, but we need it to rewrite code
    public function addServer (string $host, int $port = 11211, bool $persistent = true, int $weight = 1, float $timeout = 1, int $retry_interval = 15, bool $status = true, mixed $failure_callback = null, int $timeoutms = 0) ::: bool;
    public function rpc_connect (string $host, int $port, mixed $default_actor_id = 0, float $timeout = 0.3, float $connect_timeout = 0.3, float $reconnect_timeout = 17.0) ::: bool;
}


/** @kphp-generate-stub-class */
final class McMemcache implements Memcache {
    /** @kphp-extern-func-info generate-stub */
    public function __construct() ::: McMemcache;

    /** @kphp-extern-func-info generate-stub */
    public function get (string|string[] $key) ::: mixed;
    /** @kphp-extern-func-info generate-stub */
    public function delete (string $key) ::: bool;
    /** @kphp-extern-func-info generate-stub */
    public function add (string $key, mixed $value, int $flags = 0, int $expire = 0) ::: bool;
    /** @kphp-extern-func-info generate-stub */
    public function set (string $key, mixed $value, int $flags = 0, int $expire = 0) ::: bool;
    /** @kphp-extern-func-info generate-stub */
    public function replace (string $key, mixed $value, int $flags = 0, int $expire = 0) ::: bool;
    /** @kphp-extern-func-info generate-stub */
    public function decrement (string $key, int $v = 1) ::: mixed;
    /** @kphp-extern-func-info generate-stub */
    public function increment (string $key, int $v = 1) ::: mixed;
    /** @kphp-extern-func-info generate-stub */
    public function getVersion () ::: mixed;
    /** @kphp-extern-func-info generate-stub */
    public function addServer (string $host, int $port = 11211, bool $persistent = true, int $weight = 1, float $timeout = 1, int $retry_interval = 15, bool $status = true, mixed $failure_callback = null, int $timeoutms = 0) ::: bool;

    /** @kphp-extern-func-info generate-stub */
    public function rpc_connect (string $host, int $port, mixed $default_actor_id = 0, float $timeout = 0.3, float $connect_timeout = 0.3, float $reconnect_timeout = 17.0) ::: bool;
}