44
55namespace Smoren \ArrayView \Interfaces ;
66
7+ use Smoren \ArrayView \Exceptions \IndexError ;
8+ use Smoren \ArrayView \Exceptions \KeyError ;
9+ use Smoren \ArrayView \Exceptions \NotSupportedError ;
10+ use Smoren \ArrayView \Exceptions \ReadonlyError ;
11+ use Smoren \ArrayView \Exceptions \SizeError ;
12+ use Smoren \ArrayView \Exceptions \ValueError ;
13+
714/**
815 * Interface for a view of an array with additional methods
916 * for filtering, mapping, and transforming the data.
@@ -27,6 +34,9 @@ interface ArrayViewInterface extends \ArrayAccess, \IteratorAggregate, \Countabl
2734 * @param bool|null $readonly Optional flag to indicate whether the view should be readonly.
2835 *
2936 * @return ArrayViewInterface<T> An ArrayView instance based on the source array or ArrayView.
37+ *
38+ * @throws ValueError if the array is not sequential.
39+ * @throws ReadonlyError if the source is readonly and trying to create a non-readonly view.
3040 */
3141 public static function toView (&$ source , ?bool $ readonly = null ): ArrayViewInterface ;
3242
@@ -42,6 +52,9 @@ public static function toView(&$source, ?bool $readonly = null): ArrayViewInterf
4252 * @param bool|null $readonly Optional flag to indicate whether the view should be readonly.
4353 *
4454 * @return ArrayViewInterface<T> An ArrayView instance based on the source array or ArrayView.
55+ *
56+ * @throws ValueError if the array is not sequential.
57+ * @throws ReadonlyError if the source is readonly and trying to create a non-readonly view.
4558 */
4659 public static function toUnlinkedView ($ source , ?bool $ readonly = null ): ArrayViewInterface ;
4760
@@ -98,6 +111,9 @@ public function apply(callable $mapper): self;
98111 * @param callable(T, U, int): T $mapper Function to transform each pair of elements.
99112 *
100113 * @return ArrayViewInterface<T> this view.
114+ *
115+ * @throws ValueError if the $data is not sequential array.
116+ * @throws SizeError if size of $data not equals to size of the view.
101117 */
102118 public function applyWith ($ data , callable $ mapper ): self ;
103119
@@ -107,6 +123,9 @@ public function applyWith($data, callable $mapper): self;
107123 * @param array<T>|ArrayViewInterface<T>|T $newValues The new values to set.
108124 *
109125 * @return ArrayViewInterface<T> this view.
126+ *
127+ * @throws ValueError if the $newValues is not sequential array.
128+ * @throws SizeError if size of $newValues not equals to size of the view.
110129 */
111130 public function set ($ newValues ): self ;
112131
@@ -138,6 +157,9 @@ public function offsetExists($offset): bool;
138157 *
139158 * @return T|array<T>
140159 *
160+ * @throws IndexError if the offset is out of range.
161+ * @throws KeyError if the key is invalid.
162+ *
141163 * {@inheritDoc}
142164 */
143165 #[\ReturnTypeWillChange]
@@ -149,6 +171,10 @@ public function offsetGet($offset);
149171 *
150172 * @return void
151173 *
174+ * @throws IndexError if the offset is out of range.
175+ * @throws KeyError if the key is invalid.
176+ * @throws ReadonlyError if the object is readonly.
177+ *
152178 * {@inheritDoc}
153179 */
154180 public function offsetSet ($ offset , $ value ): void ;
@@ -158,6 +184,8 @@ public function offsetSet($offset, $value): void;
158184 *
159185 * @return void
160186 *
187+ * @throws NotSupportedError always.
188+ *
161189 * {@inheritDoc}
162190 */
163191 public function offsetUnset ($ offset ): void ;
0 commit comments