@@ -58,18 +58,18 @@ divide(1, 1); // Some(1)
58
58
/**
59
59
* @immutable
60
60
*
61
- * @implements OptionInterface< TValue >
61
+ * @template TSome
62
62
*
63
- * @template TValue
63
+ * @extends OptionInterface< TSome >
64
64
*/
65
65
interface SomeInterface extends OptionInterface
66
66
{
67
67
/**
68
- * @template TSomeValue
68
+ * @template TValue
69
69
*
70
- * @param TSomeValue $value
70
+ * @param TValue $value
71
71
*
72
- * @return self<TSomeValue >
72
+ * @return self<TValue >
73
73
*/
74
74
public static function create(mixed $value): self;
75
75
}
@@ -81,13 +81,13 @@ interface SomeInterface extends OptionInterface
81
81
/**
82
82
* @immutable
83
83
*
84
- * @implements OptionInterface< TValue >
84
+ * @template TNone of null
85
85
*
86
- * @template TValue
86
+ * @extends OptionInterface< TNone >
87
87
*/
88
88
interface NoneInterface extends OptionInterface
89
89
{
90
- /** @return self<TValue > */
90
+ /** @return self<TNone > */
91
91
public static function create(): self;
92
92
}
93
93
```
@@ -96,14 +96,22 @@ interface NoneInterface extends OptionInterface
96
96
97
97
``` php
98
98
/**
99
- * @implements IteratorAggregate< TValue >
99
+ * @immutable
100
100
*
101
101
* @template TValue
102
+ *
103
+ * @extends IteratorAggregate<int ,TValue >
102
104
*/
103
105
interface OptionInterface extends IteratorAggregate
104
106
{
105
107
/**
106
108
* 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 >
107
115
*/
108
116
public function and(self $option): self;
109
117
@@ -112,7 +120,7 @@ interface OptionInterface extends IteratorAggregate
112
120
*
113
121
* @template TAndThen
114
122
*
115
- * @param callable(TValue):self $function
123
+ * @param callable(TValue):TAndThen $function
116
124
*
117
125
* @return self<TAndThen |TValue >
118
126
*/
@@ -121,7 +129,9 @@ interface OptionInterface extends IteratorAggregate
121
129
/**
122
130
* Returns true if the option is a Some value containing the given $value.
123
131
*
124
- * @param TValue $value
132
+ * @template TContainsValue
133
+ *
134
+ * @param TContainsValue $value
125
135
*/
126
136
public function contains(mixed $value): bool;
127
137
@@ -151,7 +161,7 @@ interface OptionInterface extends IteratorAggregate
151
161
*/
152
162
public function flatten(): self;
153
163
154
- public function getIterator(): Traversable ;
164
+ public function getIterator(): Generator ;
155
165
156
166
/**
157
167
* Returns true if the Option is an instance of None.
@@ -170,7 +180,7 @@ interface OptionInterface extends IteratorAggregate
170
180
*
171
181
* @param callable(TValue):TMap $function
172
182
*
173
- * @return self<TMap >
183
+ * @return self<TMap |TValue >
174
184
*/
175
185
public function map(callable $function): self;
176
186
@@ -200,24 +210,17 @@ interface OptionInterface extends IteratorAggregate
200
210
*/
201
211
public function mapOrElse(callable $function, callable $fallback): mixed;
202
212
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
-
216
213
/**
217
214
* Returns the option if it contains a value, otherwise returns $option.
218
215
*
219
216
* Arguments passed to or are eagerly evaluated; if you are passing the result of a function call, it is recommended
220
217
* to use orElse, which is lazily evaluated.
218
+ *
219
+ * @template TOr
220
+ *
221
+ * @param self<TOr > $option
222
+ *
223
+ * @return self<TOr |TValue >
221
224
*/
222
225
public function or(self $option): self;
223
226
@@ -226,7 +229,9 @@ interface OptionInterface extends IteratorAggregate
226
229
*
227
230
* @template TCallableResultValue
228
231
*
229
- * @param callable(): OptionInterface<TCallableResultValue > $function
232
+ * @param callable(): self<TCallableResultValue > $function
233
+ *
234
+ * @return self<TCallableResultValue |TValue >
230
235
*/
231
236
public function orElse(callable $function): self;
232
237
0 commit comments