1: <?php declare(strict_types=1);
2:
3: namespace Salient\Collection;
4:
5: use Salient\Contract\Collection\ListInterface;
6: use Salient\Contract\Core\Immutable;
7: use Salient\Core\Concern\HasMutator;
8: use Salient\Core\Concern\ImmutableArrayAccessTrait;
9:
10: /**
11: * Implements ListInterface for immutable lists
12: *
13: * Mutable lists should use {@see ListTrait} instead.
14: *
15: * @see ListInterface
16: *
17: * @api
18: *
19: * @template TValue
20: *
21: * @phpstan-require-implements ListInterface
22: * @phpstan-require-implements Immutable
23: */
24: trait ImmutableListTrait
25: {
26: /** @use ListTrait<int,TValue> */
27: use ListTrait;
28: /** @use ImmutableArrayAccessTrait<int,TValue> */
29: use ImmutableArrayAccessTrait {
30: ImmutableArrayAccessTrait::offsetSet insteadof ListTrait;
31: ImmutableArrayAccessTrait::offsetUnset insteadof ListTrait;
32: }
33: use HasMutator;
34:
35: /**
36: * @return static
37: */
38: protected function maybeClone()
39: {
40: return clone $this;
41: }
42: }
43: