2022-12-30 21:54:44 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2020-04-25 21:57:55 +02:00
|
|
|
|
|
|
|
namespace danog\MadelineProto\Db;
|
|
|
|
|
2021-09-05 19:28:22 +02:00
|
|
|
use Amp\Iterator;
|
2022-12-30 19:21:36 +01:00
|
|
|
use ArrayAccess;
|
2023-01-03 22:07:58 +01:00
|
|
|
use Countable;
|
2020-04-28 02:41:06 +02:00
|
|
|
|
2020-10-03 15:04:35 +02:00
|
|
|
/**
|
|
|
|
* DB array interface.
|
|
|
|
*
|
2023-01-19 17:14:04 +01:00
|
|
|
* @template TKey as array-key
|
|
|
|
* @template TValue
|
|
|
|
*
|
|
|
|
* @extends ArrayAccess<TKey, TValue>
|
2020-10-03 15:04:35 +02:00
|
|
|
*/
|
2023-01-03 22:07:58 +01:00
|
|
|
interface DbArray extends DbType, ArrayAccess, Countable
|
2020-04-25 21:57:55 +02:00
|
|
|
{
|
2020-10-03 15:04:35 +02:00
|
|
|
/**
|
|
|
|
* Get Array copy.
|
|
|
|
*
|
2023-01-25 16:32:48 +01:00
|
|
|
* @return array<TKey, TValue>
|
2020-10-03 15:04:35 +02:00
|
|
|
*/
|
2023-01-03 22:07:58 +01:00
|
|
|
public function getArrayCopy(): array;
|
2020-10-03 15:04:35 +02:00
|
|
|
/**
|
|
|
|
* Check if element is set.
|
2023-01-25 16:32:48 +01:00
|
|
|
*
|
|
|
|
* @param TKey $key
|
2020-10-03 15:04:35 +02:00
|
|
|
*/
|
2023-01-03 22:07:58 +01:00
|
|
|
public function isset(string|int $key): bool;
|
2021-12-06 20:20:43 +01:00
|
|
|
/**
|
|
|
|
* Unset element.
|
2023-01-25 16:32:48 +01:00
|
|
|
*
|
|
|
|
* @param TKey $key
|
2021-12-06 20:20:43 +01:00
|
|
|
*/
|
2023-01-03 22:07:58 +01:00
|
|
|
public function unset(string|int $key): void;
|
2021-12-06 20:20:43 +01:00
|
|
|
/**
|
|
|
|
* Set element.
|
2023-01-25 16:32:48 +01:00
|
|
|
*
|
|
|
|
* @param TKey $key
|
|
|
|
* @param TValue $value
|
2021-12-06 20:20:43 +01:00
|
|
|
*/
|
2023-01-03 22:07:58 +01:00
|
|
|
public function set(string|int $key, mixed $value): void;
|
2020-10-03 15:04:35 +02:00
|
|
|
/**
|
|
|
|
* Get element.
|
|
|
|
*
|
2023-01-25 16:32:48 +01:00
|
|
|
* @param TKey $index
|
2020-10-03 15:04:35 +02:00
|
|
|
*/
|
2023-01-03 22:07:58 +01:00
|
|
|
public function offsetGet(mixed $index): mixed;
|
2020-10-03 15:04:35 +02:00
|
|
|
/**
|
|
|
|
* Set element.
|
|
|
|
*
|
2023-01-25 16:32:48 +01:00
|
|
|
* @param TKey $index
|
|
|
|
* @param TValue $value
|
2020-10-03 15:04:35 +02:00
|
|
|
*/
|
2022-12-30 19:21:36 +01:00
|
|
|
public function offsetSet(mixed $index, mixed $value): void;
|
2020-10-03 15:04:35 +02:00
|
|
|
/**
|
|
|
|
* Unset element.
|
2023-01-25 16:32:48 +01:00
|
|
|
* @param TKey $index Offset
|
2021-12-06 20:20:43 +01:00
|
|
|
*/
|
|
|
|
public function offsetUnset(mixed $index): void;
|
|
|
|
/**
|
|
|
|
* @see DbArray::isset();
|
2023-01-25 16:32:48 +01:00
|
|
|
*
|
|
|
|
* @param TKey $index Offset
|
2020-10-03 15:04:35 +02:00
|
|
|
*/
|
2021-12-06 20:20:43 +01:00
|
|
|
public function offsetExists(mixed $index): bool;
|
2020-11-26 21:49:31 +01:00
|
|
|
/**
|
|
|
|
* Clear all elements.
|
|
|
|
*/
|
2023-01-03 22:07:58 +01:00
|
|
|
public function clear(): void;
|
2020-10-03 15:04:35 +02:00
|
|
|
/**
|
|
|
|
* Get iterator.
|
|
|
|
*
|
2023-01-25 16:32:48 +01:00
|
|
|
* @return \Traversable<TKey, TValue>
|
2020-10-03 15:04:35 +02:00
|
|
|
*/
|
2023-01-08 20:46:16 +01:00
|
|
|
public function getIterator(): \Traversable;
|
2020-06-16 17:52:55 +02:00
|
|
|
}
|