forked from muglug/psl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMutableIndexAccessInterface.php
61 lines (56 loc) · 1.93 KB
/
MutableIndexAccessInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace Psl\Collection;
/**
* The interface for mutable, keyed collections to enable setting and removing
* keys.
*
* @template Tk of array-key
* @template Tv
*
* @extends IndexAccessInterface<Tk, Tv>
*/
interface MutableIndexAccessInterface extends IndexAccessInterface
{
/**
* Stores a value into the current collection with the specified key,
* overwriting the previous value associated with the key.
*
* It returns the current collection, meaning changes made to the current
* collection will be reflected in the returned collection.
*
* @param Tk $k The key to which we will set the value
* @param Tv $v The value to set
*
* @return MutableIndexAccessInterface<Tk, Tv> Returns itself
*/
public function set($k, $v): MutableIndexAccessInterface;
/**
* For every element in the provided `iterable`, stores a value into the
* current collection associated with each key, overwriting the previous value
* associated with the key.
*
* It the current collection, meaning changes made to the current collection
* will be reflected in the returned collection.
*
* @param iterable<Tk, Tv> $iterable The `iterable` with the new values to set
*
* @return MutableIndexAccessInterface<Tk, Tv> Returns itself
*/
public function setAll(iterable $iterable): MutableIndexAccessInterface;
/**
* Removes the specified key (and associated value) from the current
* collection.
*
* If the key is not in the current collection, the current collection is
* unchanged.
*
* It the current collection, meaning changes made to the current collection
* will be reflected in the returned collection.
*
* @param Tk $k The key to remove
*
* @return MutableIndexAccessInterface<Tk, Tv> Returns itself
*/
public function remove($k): MutableIndexAccessInterface;
}