Skip to content

Commit 0f4b45f

Browse files
committed
Enhance the Undefined type documentation
1 parent f19420c commit 0f4b45f

File tree

6 files changed

+54
-0
lines changed

6 files changed

+54
-0
lines changed

src/Undefined/Alias/NotExist.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\Undefined\UndefinedStandard;
88

99
/**
10+
* Implementation for a special "NotExist" typed value.
11+
*
12+
* Use it in APIs that must return a typed value when no meaningful value is available yet.
13+
* Prefer this over null to make intent explicit and keep type-safety.
14+
*
15+
* Example
16+
* - return NotExist::create();
17+
* - $v->toString(); // throws UndefinedTypeException
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class NotExist extends UndefinedStandard

src/Undefined/Alias/NotFound.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\Undefined\UndefinedStandard;
88

99
/**
10+
* Implementation for a special "NotFound" typed value.
11+
*
12+
* Use it in APIs that must return a typed value when no meaningful value is available yet.
13+
* Prefer this over null to make intent explicit and keep type-safety.
14+
*
15+
* Example
16+
* - return NotFound::create();
17+
* - $v->toString(); // throws UndefinedTypeException
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class NotFound extends UndefinedStandard

src/Undefined/Alias/NotSet.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\Undefined\UndefinedStandard;
88

99
/**
10+
* Implementation for a special "NotSet" typed value.
11+
*
12+
* Use it in APIs that must return a typed value when no meaningful value is available yet.
13+
* Prefer this over null to make intent explicit and keep type-safety.
14+
*
15+
* Example
16+
* - return NotSet::create();
17+
* - $v->toString(); // throws UndefinedTypeException
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class NotSet extends UndefinedStandard

src/Undefined/Alias/Undefined.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\Undefined\UndefinedStandard;
88

99
/**
10+
* Implementation for a special "Undefined" typed value.
11+
*
12+
* Use it in APIs that must return a typed value when no meaningful value is available yet.
13+
* Prefer this over null to make intent explicit and keep type-safety.
14+
*
15+
* Example
16+
* - return Undefined::create();
17+
* - $v->toString(); // throws UndefinedTypeException
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class Undefined extends UndefinedStandard

src/Undefined/Alias/Unknown.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\Undefined\UndefinedStandard;
88

99
/**
10+
* Implementation for a special "Unknown" typed value.
11+
*
12+
* Use it in APIs that must return a typed value when no meaningful value is available yet.
13+
* Prefer this over null to make intent explicit and keep type-safety.
14+
*
15+
* Example
16+
* - return Unknown::create();
17+
* - $v->toString(); // throws UndefinedTypeException
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class Unknown extends UndefinedStandard

src/Undefined/UndefinedStandard.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
use PhpTypedValues\Abstract\Undefined\UndefinedType;
88

99
/**
10+
* Base implementation for a special "UndefinedStandard" typed value.
11+
*
12+
* Use it in APIs that must return a typed value when no meaningful value is available yet.
13+
* Prefer this over null to make intent explicit and keep type-safety.
14+
*
15+
* Example
16+
* - return UndefinedStandard::create();
17+
* - $v->toString(); // throws UndefinedTypeException
18+
*
1019
* @psalm-immutable
1120
*/
1221
readonly class UndefinedStandard extends UndefinedType

0 commit comments

Comments
 (0)