MadelineProto/src/danog/MadelineProto/Db/DbArray.php

85 lines
1.6 KiB
PHP
Raw Normal View History

2020-04-25 21:57:55 +02:00
<?php
namespace danog\MadelineProto\Db;
2020-04-28 02:41:06 +02:00
use Amp\Producer;
use Amp\Promise;
2020-10-03 15:04:35 +02:00
/**
* DB array interface.
*
* @template T as mixed
*/
2020-05-03 03:33:54 +02: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.
*
2020-10-15 19:07:37 +02:00
* @psalm-return Promise<array<string|int, T>>
2020-10-03 15:04:35 +02:00
*
* @return Promise
*/
public function getArrayCopy(): Promise;
2020-10-03 15:04:35 +02:00
/**
* Check if element is set.
*
* @param string|int $key
*
* @psalm-return Promise<bool>
*
* @return Promise
*/
public function isset($key): Promise;
2020-10-03 15:04:35 +02:00
/**
* Get element.
*
2020-10-04 14:55:05 +02:00
* @param string|int $index
2020-10-03 15:04:35 +02:00
*
* @psalm-return Promise<T>
*
* @return Promise
*/
2020-10-04 14:55:05 +02:00
public function offsetGet($index): Promise;
2020-10-03 15:04:35 +02:00
/**
* Set element.
*
2020-10-04 14:55:05 +02:00
* @param string|int $index
2020-10-03 15:04:35 +02:00
* @param mixed $value
*
* @psalm-param T $value
*
* @return void
*/
2020-10-04 14:55:05 +02:00
public function offsetSet($index, $value);
2020-10-03 15:04:35 +02:00
/**
* Unset element.
*
2020-10-04 14:55:05 +02:00
* @param string|int $index Offset
2020-10-03 15:04:35 +02:00
* @return Promise
*/
2020-10-04 14:55:05 +02:00
public function offsetUnset($index): Promise;
2020-10-03 15:04:35 +02:00
/**
* Count number of elements.
*
* @return Promise<integer>
*/
2020-05-03 03:33:54 +02:00
public function count(): Promise;
2020-10-03 15:04:35 +02:00
/**
* Get iterator.
*
* @return Producer<array{0: string|int, 1: T}>
*/
2020-04-28 02:41:06 +02:00
public function getIterator(): Producer;
/**
* @deprecated
* @internal
* @see DbArray::isset();
*
2020-10-04 14:55:05 +02:00
* @param mixed $index
*
* @return bool
*/
2020-10-04 14:55:05 +02:00
public function offsetExists($index);
2020-06-16 17:52:55 +02:00
}