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