File tree Expand file tree Collapse file tree 4 files changed +28
-0
lines changed
Expand file tree Collapse file tree 4 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1919 * items via `value()`, supports iteration, and can be converted to a plain
2020 * array or JSON.
2121 *
22+ * Example
23+ * - $a = ArrayOfStrings::fromArray(['foo', 'bar']);
24+ * $a->toArray(); // ['foo', 'bar']
25+ * foreach ($a as $item) { $item->toString(); // 'foo', then 'bar' }
26+ * - ArrayOfStrings::fromArray([]); // throws TypeException('Expected non-empty array')
27+ * - ArrayOfStrings::fromArray([123, 45.6]); // casts to strings → ['123', '45.6']
28+ *
2229 * @internal
2330 *
2431 * @psalm-internal PhpTypedValues
Original file line number Diff line number Diff line change 1919 * All fields must be valid on creation time. Any invalid input immediately
2020 * raises a domain exception from the underlying typed values.
2121 *
22+ * Example
23+ * - $p = EarlyFail::fromScalars(id: 1, firstName: 'Alice', height: 170.5);
24+ * $p->getFirstName()->toString(); // 'Alice'
25+ * - EarlyFail::fromScalars(id: 0, firstName: 'Alice', height: 170); // throws IntegerTypeException
26+ * - EarlyFail::fromScalars(id: 1, firstName: '', height: 170); // throws StringTypeException
27+ * - EarlyFail::fromScalars(id: 1, firstName: 'Alice', height: -1); // throws FloatTypeException
28+ *
2229 * @internal
2330 *
2431 * @psalm-internal PhpTypedValues
Original file line number Diff line number Diff line change 1919 * - `firstName` and `height` accept mixed inputs and may become `Undefined`;
2020 * accessing their string/primitive values may fail later.
2121 *
22+ * Example
23+ * - $p = LateFail::fromScalars(id: 1, firstName: 'Bob', height: '170.5');
24+ * $p->getHeight()->toString(); // '170.5'
25+ * - $p = LateFail::fromScalars(id: 1, firstName: '', height: null);
26+ * $p->getFirstName()->toString(); // late fail (UndefinedTypeException)
27+ * $p->getHeight()->toString(); // late fail (UndefinedTypeException)
28+ *
2229 * @internal
2330 *
2431 * @psalm-internal PhpTypedValues
Original file line number Diff line number Diff line change 2222 * - `firstName` uses `tryFromMixed` and may be `Undefined` (late fail on access).
2323 * - `height` fails early only when provided; `null` becomes `Undefined` (late fail).
2424 *
25+ * Example
26+ * - $p = OptionalFail::fromScalars(id: 1, firstName: 'Alice', height: 170);
27+ * $p->jsonSerialize(); // ['id' => '1', 'firstName' => 'Alice', 'height' => '170']
28+ * - $p = OptionalFail::fromScalars(id: 1, firstName: '', height: null);
29+ * $p->getFirstName()->toString(); // late fail (UndefinedTypeException)
30+ * $p->getHeight()->toString(); // late fail (UndefinedTypeException)
31+ *
2532 * @internal
2633 *
2734 * @psalm-internal PhpTypedValues
You can’t perform that action at this time.
0 commit comments