1 | <?php |
||
10 | final class Queue implements \IteratorAggregate, \ArrayAccess, Collection |
||
11 | { |
||
12 | use Traits\Collection; |
||
13 | |||
14 | const MIN_CAPACITY = 8; |
||
15 | |||
16 | /** |
||
17 | * @var Deque |
||
18 | */ |
||
19 | private $internal; |
||
20 | |||
21 | /** |
||
22 | * Creates an instance using the values of an array or Traversable object. |
||
23 | * |
||
24 | * @param array|\Traversable $values |
||
|
|||
25 | */ |
||
26 | public function __construct($values = null) |
||
27 | { |
||
28 | $this->internal = new Deque($values ?: []); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Ensures that enough memory is allocated for a specified capacity. This |
||
33 | * potentially reduces the number of reallocations as the size increases. |
||
34 | * |
||
35 | * @param int $capacity The number of values for which capacity should be |
||
36 | * allocated. Capacity will stay the same if this value |
||
37 | * is less than or equal to the current capacity. |
||
38 | */ |
||
39 | public function allocate(int $capacity) |
||
43 | |||
44 | /** |
||
45 | * Returns the current capacity of the queue. |
||
46 | * |
||
47 | * @return int |
||
48 | */ |
||
49 | public function capacity(): int |
||
53 | |||
54 | /** |
||
55 | * @inheritDoc |
||
56 | */ |
||
57 | public function clear() |
||
61 | |||
62 | /** |
||
63 | * @inheritDoc |
||
64 | */ |
||
65 | public function copy(): \Ds\Collection |
||
69 | |||
70 | /** |
||
71 | * @inheritDoc |
||
72 | */ |
||
73 | public function count(): int |
||
77 | |||
78 | /** |
||
79 | * Returns the value at the front of the queue without removing it. |
||
80 | * |
||
81 | * @return |
||
82 | */ |
||
83 | public function peek() |
||
87 | |||
88 | /** |
||
89 | * Returns and removes the value at the front of the Queue. |
||
90 | * |
||
91 | * @return mixed |
||
92 | */ |
||
93 | public function pop() |
||
97 | |||
98 | /** |
||
99 | * Pushes zero or more values into the front of the queue. |
||
100 | * |
||
101 | * @param mixed ...$values |
||
102 | */ |
||
103 | public function push(...$values) |
||
107 | |||
108 | /** |
||
109 | * @inheritDoc |
||
110 | */ |
||
111 | public function toArray(): array |
||
115 | |||
116 | /** |
||
117 | * Get iterator |
||
118 | */ |
||
119 | public function getIterator() |
||
125 | |||
126 | |||
127 | /** |
||
128 | * @inheritdoc |
||
129 | * |
||
130 | * @throws Error |
||
131 | */ |
||
132 | public function offsetSet($offset, $value) |
||
140 | |||
141 | /** |
||
142 | * @inheritdoc |
||
143 | * |
||
144 | * @throws Error |
||
145 | */ |
||
146 | public function offsetGet($offset) |
||
150 | |||
151 | /** |
||
152 | * @inheritdoc |
||
153 | * |
||
154 | * @throws Error |
||
155 | */ |
||
156 | public function offsetUnset($offset) |
||
160 | |||
161 | /** |
||
162 | * @inheritdoc |
||
163 | * |
||
164 | * @throws Error |
||
165 | */ |
||
166 | public function offsetExists($offset) |
||
170 | } |
||
171 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type
array
and suggests a stricter type likearray<String>
.Most often this is a case of a parameter that can be null in addition to its declared types.