Issues (19)

src/Interfaces/IndexedArrayInterface.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Smoren\Sequence\Interfaces;
6
7
use ArrayAccess;
8
use Countable;
9
use IteratorAggregate;
10
use Smoren\Sequence\Exceptions\OutOfRangeException;
11
use Smoren\Sequence\Iterators\IndexedArrayIterator;
12
use Smoren\Sequence\Structs\Range;
13
14
/**
15
 * Interface for Indexed Array.
16
 *
17
 * Its keys are always an unbroken sequence of natural numbers starting from zero.
18
 *
19
 * It is also allowed to access array elements from the end with negative indices.
20
 *
21
 * OutOfRangeException will be thrown when trying to access a non-existent index.
22
 *
23
 * @template T
24
 * @extends ArrayAccess<int, T>
25
 * @extends IteratorAggregate<int, T>
26
 */
27
interface IndexedArrayInterface extends ArrayAccess, Countable, IteratorAggregate
28
{
29
    /**
30
     * Returns a range of array keys.
31
     *
32
     * @return Range<int>
33
     */
34
    public function getRange(): Range;
35
36
    /**
37
     * Returns iterator for array.
38
     *
39
     * @return IndexedArrayIterator<T>
40
     */
41
    public function getIterator(): IndexedArrayIterator;
42
43
    /**
44
     * {@inheritDoc}
45
     *
46
     * @param int $offset
47
     *
48
     * @return bool
49
     */
50
    public function offsetExists($offset): bool;
51
52
    /**
53
     * {@inheritDoc}
54
     *
55
     * @param int $offset
56
     *
57
     * @return T
0 ignored issues
show
The type Smoren\Sequence\Interfaces\T 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...
58
     *
59
     * @throws OutOfRangeException if key does not exist in array
60
     */
61
    #[\ReturnTypeWillChange]
62
    public function offsetGet($offset);
63
64
    /**
65
     * {@inheritDoc}
66
     *
67
     * @param int|null $offset
68
     * @param T $value
69
     *
70
     * @return void
71
     *
72
     * @throws OutOfRangeException if key is not null and does not exist in array
73
     */
74
    public function offsetSet($offset, $value): void;
75
76
    /**
77
     * {@inheritDoc}
78
     *
79
     * @param int $offset
80
     *
81
     * @return void
82
     *
83
     * @throws OutOfRangeException if key does not exist in array
84
     */
85
    public function offsetUnset($offset): void;
86
87
    /**
88
     * {@inheritDoc}
89
     */
90
    public function count(): int;
91
92
    /**
93
     * Converts IndexedArray to PHP array.
94
     *
95
     * @return array<T>
96
     */
97
    public function toArray(): array;
98
}
99