12
12
* # Examples
13
13
*
14
14
* ```
15
- * use TH\Maybe\Option;
16
- *
17
15
* // @return Option<float>
18
16
* function divide(float $numerator, float $denominator): Option {
19
17
* if ($denominator === 0.0) {
@@ -50,15 +48,11 @@ interface Option extends \IteratorAggregate
50
48
* # Examples
51
49
*
52
50
* ```
53
- * use TH\Maybe\Option;
54
- *
55
51
* $x = Option\some("value");
56
52
* self::assertSame($x->expect("fruits are healthy"), "value");
57
53
* ```
58
54
*
59
55
* ```
60
- * use TH\Maybe\Option;
61
- *
62
56
* // @var Option<string> $x
63
57
* $x = Option\none();
64
58
*
@@ -78,15 +72,11 @@ public function expect(string $message): mixed;
78
72
* # Examples
79
73
*
80
74
* ```
81
- * use TH\Maybe\Option;
82
- *
83
75
* $x = Option\some("value");
84
76
* self::assertSame($x->unwrap(), "value");
85
77
* ```
86
78
*
87
79
* ```
88
- * use TH\Maybe\Option;
89
- *
90
80
* // @var Option<string> $x
91
81
* $x = Option\none();
92
82
*
@@ -105,8 +95,6 @@ public function unwrap(): mixed;
105
95
* # Examples
106
96
*
107
97
* ```
108
- * use TH\Maybe\Option;
109
- *
110
98
* self::assertSame(Option\some("car")->unwrapOr("bike"), "car");
111
99
* self::assertSame(Option\none()->unwrapOr("bike"), "bike");
112
100
* ```
@@ -122,8 +110,6 @@ public function unwrapOr(mixed $default): mixed;
122
110
* # Examples
123
111
*
124
112
* ```
125
- * use TH\Maybe\Option;
126
- *
127
113
* $k = 10;
128
114
* self::assertSame(Option\some(4)->unwrapOrElse(fn () => 2 * $k), 4);
129
115
* self::assertSame(Option\none()->unwrapOrElse(fn () => 2 * $k), 20);
@@ -141,8 +127,6 @@ public function unwrapOrElse(callable $default): mixed;
141
127
* # Examples
142
128
*
143
129
* ```
144
- * use TH\Maybe\Option;
145
- *
146
130
* $option = Option\some(4);
147
131
* self::assertSame($option->inspect(fn (int $n) => printf("got: %d", $n)), $option); // @prints got: 4
148
132
* // @var Option<int> $option
@@ -161,8 +145,6 @@ public function inspect(callable $callback): self;
161
145
* # Examples
162
146
*
163
147
* ```
164
- * use TH\Maybe\Option;
165
- *
166
148
* $x = Option\some(2);
167
149
* // @var Option<string> $y
168
150
* $y = Option\none();
@@ -193,8 +175,6 @@ public function and(Option $right): Option;
193
175
* # Examples
194
176
*
195
177
* ```
196
- * use TH\Maybe\Option;
197
- *
198
178
* // @return Option<int>
199
179
* function to_exact_int(float $f): Option {
200
180
* $i = (int) $f;
@@ -218,8 +198,6 @@ public function andThen(callable $right): Option;
218
198
* # Examples
219
199
*
220
200
* ```
221
- * use TH\Maybe\Option;
222
- *
223
201
* $x = Option\some(2);
224
202
* // @var Option<int> $y
225
203
* $y = Option\none();
@@ -252,8 +230,6 @@ public function or(Option $right): Option;
252
230
* # Examples
253
231
*
254
232
* ```
255
- * use TH\Maybe\Option;
256
- *
257
233
* // @return Option<string>
258
234
* function nobody(): Option {
259
235
* return Option\none();
@@ -280,8 +256,6 @@ public function orElse(callable $right): Option;
280
256
* # Examples
281
257
*
282
258
* ```
283
- * use TH\Maybe\Option;
284
- *
285
259
* $x = Option\some(2);
286
260
* // @var Option<int> $y
287
261
* $y = Option\none();
@@ -311,8 +285,6 @@ public function xor(Option $right): Option;
311
285
* # Examples
312
286
*
313
287
* ```
314
- * use TH\Maybe\Option;
315
- *
316
288
* $x = Option\some(2);
317
289
* self::assertTrue($x->contains(2));
318
290
* $x = Option\some(3);
@@ -332,8 +304,6 @@ public function contains(mixed $value, bool $strict = true): bool;
332
304
* # Examples
333
305
*
334
306
* ```
335
- * use TH\Maybe\Option;
336
- *
337
307
* $isEven = fn(int $n) => $n % 2 === 0;
338
308
*
339
309
* self::assertSame(Option\none()->filter($isEven), Option\none());
@@ -352,8 +322,6 @@ public function filter(callable $predicate): Option;
352
322
* # Examples
353
323
*
354
324
* ```
355
- * use TH\Maybe\Option;
356
- *
357
325
* $maybeSomeString = Option\some("Hello, World!");
358
326
* $maybeSomeLen = $maybeSomeString->map(strlen(...));
359
327
* self::assertEq($maybeSomeLen, Option\some(13));
@@ -372,8 +340,6 @@ public function map(callable $callback): Option;
372
340
* # Examples
373
341
*
374
342
* ```
375
- * use TH\Maybe\Option;
376
- *
377
343
* $x = Option\some("foo");
378
344
* self::assertSame($x->mapOr(strlen(...), 42), 3);
379
345
* // @var Option<string> $x
@@ -395,8 +361,6 @@ public function mapOr(callable $callback, mixed $default): mixed;
395
361
* # Examples
396
362
*
397
363
* ```
398
- * use TH\Maybe\Option;
399
- *
400
364
* $k = 21;
401
365
* $x = Option\some("foo");
402
366
* self::assertSame($x->mapOrElse(strlen(...), fn () => 2 * $k), 3);
@@ -421,8 +385,6 @@ public function mapOrElse(callable $callback, callable $default): mixed;
421
385
* # Examples
422
386
*
423
387
* ```
424
- * use TH\Maybe\Option;
425
- *
426
388
* $x = Option\some(1);
427
389
* $y = Option\some("hi");
428
390
* // @var Option<int> $z
@@ -443,7 +405,7 @@ public function zip(Option $option): Option;
443
405
* # Examples
444
406
*
445
407
* ```
446
- * use TH\Maybe\{Option, Result} ;
408
+ * use TH\Maybe\Result;
447
409
*
448
410
* self::assertEq(Option\some("foo")->okOr(0), Result\ok("foo"));
449
411
* self::assertEq(Option\none()->okOr(0), Result\err(0));
@@ -462,7 +424,7 @@ public function okOr(mixed $err): Result;
462
424
* # Examples
463
425
*
464
426
* ```
465
- * use TH\Maybe\{Option, Result} ;
427
+ * use TH\Maybe\Result;
466
428
*
467
429
* self::assertEq(Option\some("foo")->okOrElse(fn () => 0), Result\ok("foo"));
468
430
* self::assertEq(Option\none()->okOrElse(fn () => 0), Result\err(0));
0 commit comments