Skip to content

Commit 6d27d31

Browse files
committed
feat: add an sample data stream api implements
1 parent 0b39c7d commit 6d27d31

File tree

7 files changed

+899
-27
lines changed

7 files changed

+899
-27
lines changed

src/Util/Optional.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@
2020
final class Optional
2121
{
2222
/**
23-
* @var self
23+
* @var self|null
2424
*/
25-
private static $empty;
25+
private static ?Optional $empty;
2626

2727
/**
2828
* Returns an Optional with the specified present non-null value.
2929
*
3030
* @template S
31+
*
3132
* @param S $value
3233
*
3334
* @return static
3435
*/
35-
public static function of($value): self
36+
public static function of(mixed $value): self
3637
{
3738
return new self(Obj::requireNotNull($value));
3839
}
@@ -54,38 +55,38 @@ public static function empty(): self
5455
*
5556
* @template S
5657
*
57-
* @param S $value The actual return value.
58-
* @param S $nullValue The value which should be considered "None"; null by default.
58+
* @param S $value The actual return value.
59+
* @param S|null $nullValue The value which should be considered "None"; null by default.
5960
*
6061
* @return static
6162
*/
62-
public static function nullable($value, $nullValue = null): self
63+
public static function nullable(mixed $value, mixed $nullValue = null): self
6364
{
6465
return $value === $nullValue ? self::empty() : self::of($value);
6566
}
6667

6768
/**
6869
* @template S
6970
*
70-
* @param S $value
71-
* @param S $nullValue
71+
* @param S $value
72+
* @param S|null $nullValue
7273
*
7374
* @return static
7475
*/
75-
public static function ofNullable($value, $nullValue = null): self
76+
public static function ofNullable(mixed $value, mixed $nullValue = null): self
7677
{
7778
return self::nullable($value, $nullValue);
7879
}
7980

8081
/**
8182
* @template S
8283
*
83-
* @param array|ArrayAccess $array
84-
* @param string|int $key
84+
* @param ArrayAccess|array $array
85+
* @param int|string $key
8586
*
8687
* @return static
8788
*/
88-
public static function ofArrayKey($array, $key): self
89+
public static function ofArrayKey(ArrayAccess|array $array, int|string $key): self
8990
{
9091
if (!(is_array($array) || $array instanceof ArrayAccess) || !isset($array[$key])) {
9192
return self::empty();
@@ -102,14 +103,14 @@ public static function ofReturn(callable $fn): self
102103
/**
103104
* @var T
104105
*/
105-
private $value;
106+
private mixed $value;
106107

107108
/**
108109
* Class constructor.
109110
*
110111
* @param T $value
111112
*/
112-
private function __construct($value)
113+
private function __construct(mixed $value)
113114
{
114115
$this->value = $value;
115116
}

src/Util/Stream/BaseStream.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)