1313use PhpTypedValues \String \StringNonEmpty ;
1414
1515/**
16+ * Immutable collection of non-empty strings represented as `StringNonEmpty`.
17+ *
18+ * Provides factory helpers to construct from raw arrays, exposes the typed
19+ * items via `value()`, supports iteration, and can be converted to a plain
20+ * array or JSON.
21+ *
1622 * @internal
1723 *
1824 * @psalm-internal PhpTypedValues
2430final readonly class ArrayOfStrings extends ArrayType
2531{
2632 /**
27- * @param non-empty-list<StringNonEmpty> $value
33+ * Creates a new collection from a non-empty list of `StringNonEmpty`.
34+ *
35+ * @param non-empty-list<StringNonEmpty> $value items must be instances of `StringNonEmpty`
2836 *
2937 * @throws StringTypeException
3038 * @throws TypeException
@@ -45,6 +53,11 @@ public function __construct(
4553 }
4654
4755 /**
56+ * Creates a collection from a non-empty list of raw values by casting each
57+ * value to string and validating it as `StringNonEmpty`.
58+ *
59+ * @param array $value raw values to convert
60+ *
4861 * @psalm-param list<mixed> $value
4962 *
5063 * @throws StringTypeException
@@ -66,6 +79,11 @@ public static function fromArray(array $value): static
6679 }
6780
6881 /**
82+ * Same as `fromArray()` but intended for scenarios where late/optional
83+ * failure might be desirable. Current implementation mirrors `fromArray()`.
84+ *
85+ * @param array $value raw values to convert
86+ *
6987 * @psalm-param list<mixed> $value
7088 *
7189 * @throws StringTypeException
@@ -77,6 +95,8 @@ public static function tryFromArray(array $value): static
7795 }
7896
7997 /**
98+ * Returns the underlying typed items.
99+ *
80100 * @psalm-return non-empty-list<StringNonEmpty>
81101 */
82102 public function value (): array
@@ -85,6 +105,8 @@ public function value(): array
85105 }
86106
87107 /**
108+ * Converts the collection to a non-empty list of raw strings.
109+ *
88110 * @return non-empty-list<non-empty-string>
89111 */
90112 public function toArray (): array
@@ -101,6 +123,8 @@ public function toArray(): array
101123 }
102124
103125 /**
126+ * JSON serialization proxy that returns the same as `toArray()`.
127+ *
104128 * @return non-empty-list<non-empty-string>
105129 */
106130 public function jsonSerialize (): array
@@ -109,6 +133,8 @@ public function jsonSerialize(): array
109133 }
110134
111135 /**
136+ * Iterates over the underlying `StringNonEmpty` items.
137+ *
112138 * @return Generator<int, StringNonEmpty>
113139 */
114140 public function getIterator (): Generator
0 commit comments