Issues (50)

src/TableInterface.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Bdf\Collection;
4
5
use ArrayAccess;
6
7
/**
8
 * A table is a key-value collection
9
 *
10
 * Each elements of the table will be attached to a key
11
 *
12
 * @template K
13
 * @template T
14
 * @extends CollectionInterface<T>
15
 */
16
interface TableInterface extends CollectionInterface, ArrayAccess
17
{
18
    /**
19
     * Set a value to the table with a key
20
     *
21
     * @param K $key The key where the value will be stored
0 ignored issues
show
The type Bdf\Collection\K was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
     * @param T $value The value to store
23
     *
24
     * @return void
25
     */
26
    public function set($key, $value): void;
27
28
    /**
29
     * Get a value at the specified index
30
     *
31
     * @param K $key The key to search
32
     *
33
     * @return T
34
     *
35
     * @throws \OutOfBoundsException When cannot found the element at the given key
36
     */
37
    public function &get($key);
38
39
    /**
40
     * {@inheritdoc}
41
     *
42
     * The element will be store at a generated key, like an increment
43
     * Some implementation may not supports generation of key, and this method will return false, without store the value
44
     *
45
     * @param T $element
46
     */
47
    public function add($element): bool;
48
49
    /**
50
     * {@inheritdoc}
51
     *
52
     * @param iterable<K, T> $elements
53
     */
54
    public function addAll(iterable $elements): bool;
55
56
    /**
57
     * {@inheritdoc}
58
     *
59
     * @param iterable<K, T> $elements
60
     */
61
    public function replace(iterable $elements): bool;
62
63
    /**
64
     * Check if the table has the given key
65
     *
66
     * @param K $key The key to check
67
     *
68
     * @return boolean true if the table has the key
69
     */
70
    public function hasKey($key): bool;
71
72
    /**
73
     * Remove an element at the given key
74
     *
75
     * @param K $key The key to remove
76
     *
77
     * @return boolean true if the key exists, and the element is successfully removed
78
     */
79
    public function unset($key): bool;
80
81
    /**
82
     * Get all the keys of the table
83
     *
84
     * @return K[]
85
     */
86
    public function keys(): array;
87
88
    /**
89
     * Get all values (elements) of the table
90
     *
91
     * @return T[]
92
     */
93
    public function values(): array;
94
95
    /**
96
     * {@inheritdoc}
97
     *
98
     * The consumer should have two parameters :
99
     * - The element
100
     * - The key
101
     *
102
     * Ex:
103
     * <code>
104
     * $collection->forEach(function ($element, $key) {
105
     *     $element->doSomething();
106
     * });
107
     * </code>
108
     *
109
     * @param callable(T, K=):void $consumer
110
     */
111
    public function forEach(callable $consumer): void;
112
113
    /**
114
     * {@inheritdoc}
115
     *
116
     * @param K $offset
117
     * @param T $value
118
     *
119
     * @return void
120
     */
121
    public function offsetSet($offset, $value): void;
122
123
    /**
124
     * {@inheritdoc}
125
     *
126
     * @param K $offset
127
     * @return T
128
     */
129
    #[\ReturnTypeWillChange]
130
    public function &offsetGet($offset);
131
}
132