Skip to content

Commit f6ab1c1

Browse files
committed
Update README.md
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
1 parent be01fa2 commit f6ab1c1

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

README.md

+32-27
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ divide(1, 1); // Some(1)
5858
/**
5959
* @immutable
6060
*
61-
* @implements OptionInterface<TValue>
61+
* @template TSome
6262
*
63-
* @template TValue
63+
* @extends OptionInterface<TSome>
6464
*/
6565
interface SomeInterface extends OptionInterface
6666
{
6767
/**
68-
* @template TSomeValue
68+
* @template TValue
6969
*
70-
* @param TSomeValue $value
70+
* @param TValue $value
7171
*
72-
* @return self<TSomeValue>
72+
* @return self<TValue>
7373
*/
7474
public static function create(mixed $value): self;
7575
}
@@ -81,13 +81,13 @@ interface SomeInterface extends OptionInterface
8181
/**
8282
* @immutable
8383
*
84-
* @implements OptionInterface<TValue>
84+
* @template TNone of null
8585
*
86-
* @template TValue
86+
* @extends OptionInterface<TNone>
8787
*/
8888
interface NoneInterface extends OptionInterface
8989
{
90-
/** @return self<TValue> */
90+
/** @return self<TNone> */
9191
public static function create(): self;
9292
}
9393
```
@@ -96,14 +96,22 @@ interface NoneInterface extends OptionInterface
9696

9797
``` php
9898
/**
99-
* @implements IteratorAggregate<TValue>
99+
* @immutable
100100
*
101101
* @template TValue
102+
*
103+
* @extends IteratorAggregate<int,TValue>
102104
*/
103105
interface OptionInterface extends IteratorAggregate
104106
{
105107
/**
106108
* Returns None if the Option is None, otherwise returns $option.
109+
*
110+
* @template TAnd
111+
*
112+
* @param self<TAnd> $option
113+
*
114+
* @return self<TAnd|TValue>
107115
*/
108116
public function and(self $option): self;
109117

@@ -112,7 +120,7 @@ interface OptionInterface extends IteratorAggregate
112120
*
113121
* @template TAndThen
114122
*
115-
* @param callable(TValue):self $function
123+
* @param callable(TValue):TAndThen $function
116124
*
117125
* @return self<TAndThen|TValue>
118126
*/
@@ -121,7 +129,9 @@ interface OptionInterface extends IteratorAggregate
121129
/**
122130
* Returns true if the option is a Some value containing the given $value.
123131
*
124-
* @param TValue $value
132+
* @template TContainsValue
133+
*
134+
* @param TContainsValue $value
125135
*/
126136
public function contains(mixed $value): bool;
127137

@@ -151,7 +161,7 @@ interface OptionInterface extends IteratorAggregate
151161
*/
152162
public function flatten(): self;
153163

154-
public function getIterator(): Traversable;
164+
public function getIterator(): Generator;
155165

156166
/**
157167
* Returns true if the Option is an instance of None.
@@ -170,7 +180,7 @@ interface OptionInterface extends IteratorAggregate
170180
*
171181
* @param callable(TValue):TMap $function
172182
*
173-
* @return self<TMap>
183+
* @return self<TMap|TValue>
174184
*/
175185
public function map(callable $function): self;
176186

@@ -200,24 +210,17 @@ interface OptionInterface extends IteratorAggregate
200210
*/
201211
public function mapOrElse(callable $function, callable $fallback): mixed;
202212

203-
/**
204-
* Creates an option with the given value.
205-
*
206-
* By default, we treat null as the None case, and everything else as Some.
207-
*
208-
* @template TNullableValue
209-
*
210-
* @param TNullableValue $value the actual value
211-
*
212-
* @return self<TNullableValue|TValue>
213-
*/
214-
public static function of(mixed $value): self;
215-
216213
/**
217214
* Returns the option if it contains a value, otherwise returns $option.
218215
*
219216
* Arguments passed to or are eagerly evaluated; if you are passing the result of a function call, it is recommended
220217
* to use orElse, which is lazily evaluated.
218+
*
219+
* @template TOr
220+
*
221+
* @param self<TOr> $option
222+
*
223+
* @return self<TOr|TValue>
221224
*/
222225
public function or(self $option): self;
223226

@@ -226,7 +229,9 @@ interface OptionInterface extends IteratorAggregate
226229
*
227230
* @template TCallableResultValue
228231
*
229-
* @param callable(): OptionInterface<TCallableResultValue> $function
232+
* @param callable(): self<TCallableResultValue> $function
233+
*
234+
* @return self<TCallableResultValue|TValue>
230235
*/
231236
public function orElse(callable $function): self;
232237

0 commit comments

Comments
 (0)