diff --git a/src/Collection/GenericList.php b/src/Collection/GenericList.php index d49c1c5..9425182 100644 --- a/src/Collection/GenericList.php +++ b/src/Collection/GenericList.php @@ -76,6 +76,13 @@ public function map(callable $mapper): self return new Cons($mapper($this->head()), $this->tail()->map($mapper)); } + /** + * @template U + * + * @param callable(T): Traversable $mapper + * + * @return GenericList + */ public function flatMap(callable $mapper) { $list = self::empty(); @@ -224,6 +231,9 @@ public function reverse(): self return $list; } + /** + * @return GenericList + */ public function appendAll(Traversable $elements) { if ($elements->isEmpty()) { @@ -233,6 +243,9 @@ public function appendAll(Traversable $elements) return self::ofAll($elements)->prependAll($this); } + /** + * @return GenericList + */ public function prependAll(Traversable $elements) { if ($this->isEmpty()) { diff --git a/src/Collection/Stream.php b/src/Collection/Stream.php index 786f548..878853e 100644 --- a/src/Collection/Stream.php +++ b/src/Collection/Stream.php @@ -174,6 +174,13 @@ public function map(callable $mapper): self return new Cons($mapper($this->head()), function () use ($mapper) {return $this->tail()->map($mapper); }); } + /** + * @template U + * + * @param callable(T): Traversable $mapper + * + * @return Stream + */ public function flatMap(callable $mapper) { $stream = self::empty(); @@ -292,6 +299,9 @@ public function prepend($element) return new Cons($element, function () {return $this; }); } + /** + * @return Stream + */ public function prependAll(Traversable $elements) { if ($elements->isEmpty()) { diff --git a/src/Collection/Stream/Cons.php b/src/Collection/Stream/Cons.php index 7536b6f..4831a67 100644 --- a/src/Collection/Stream/Cons.php +++ b/src/Collection/Stream/Cons.php @@ -71,6 +71,9 @@ public function iterator(): Iterator return new StreamIterator($this); } + /** + * @return Stream + */ public function append($element) { return new Cons($this->head, function () use ($element) { @@ -78,6 +81,9 @@ public function append($element) }); } + /** + * @return Stream + */ public function appendAll(Traversable $elements) { if ($elements->isEmpty()) { diff --git a/src/Collection/Stream/EmptyStream.php b/src/Collection/Stream/EmptyStream.php index 71986a1..656c098 100644 --- a/src/Collection/Stream/EmptyStream.php +++ b/src/Collection/Stream/EmptyStream.php @@ -51,11 +51,17 @@ public function iterator(): Iterator return Iterator::empty(); } + /** + * @return Stream + */ public function append($element) { return Stream::of($element); } + /** + * @return Stream + */ public function appendAll(Traversable $elements) { if ($elements->isEmpty()) {