1: | <?php declare(strict_types=1); |
2: | |
3: | namespace Salient\Collection; |
4: | |
5: | use ArrayAccess; |
6: | use LogicException; |
7: | |
8: | /** |
9: | * @api |
10: | * |
11: | * @template TKey of array-key |
12: | * @template TValue |
13: | * |
14: | * @phpstan-require-implements ArrayAccess |
15: | */ |
16: | trait ReadOnlyArrayAccessTrait |
17: | { |
18: | /** |
19: | * @param TKey|null $offset |
20: | * @param TValue $value |
21: | * @return never |
22: | */ |
23: | public function offsetSet($offset, $value): void |
24: | { |
25: | throw new LogicException(sprintf( |
26: | '%s values are read-only', |
27: | static::class, |
28: | )); |
29: | } |
30: | |
31: | /** |
32: | * @param TKey $offset |
33: | * @return never |
34: | */ |
35: | public function offsetUnset($offset): void |
36: | { |
37: | throw new LogicException(sprintf( |
38: | '%s values are read-only', |
39: | static::class, |
40: | )); |
41: | } |
42: | } |
43: |