1414use function Cdn77 \Functions \mappedMapsFromIterable ;
1515use function Cdn77 \Functions \mappedQueuesFromIterable ;
1616use function Cdn77 \Functions \mappedSetsFromIterable ;
17+ use function Cdn77 \Functions \mappedVectorsFromIterable ;
1718use function Cdn77 \Functions \setFromIterable ;
1819use function Cdn77 \Functions \vectorFromIterable ;
1920
2021#[CoversFunction('Cdn77\Functions\mapFromIterable ' )]
2122#[CoversFunction('Cdn77\Functions\mappedMapsFromIterable ' )]
2223#[CoversFunction('Cdn77\Functions\mappedQueuesFromIterable ' )]
2324#[CoversFunction('Cdn77\Functions\mappedSetsFromIterable ' )]
25+ #[CoversFunction('Cdn77\Functions\mappedVectorsFromIterable ' )]
2426#[CoversFunction('Cdn77\Functions\setFromIterable ' )]
2527#[CoversFunction('Cdn77\Functions\vectorFromIterable ' )]
2628final class DsTest extends TestCase
@@ -93,7 +95,12 @@ public function testMappedQueuesFromIterable(): void
9395
9496 $ map = mappedQueuesFromIterable (
9597 $ iterableFactory (),
96- static fn (int $ key , string $ value ) => new Pair ($ key * 2 , $ value . '_ ' ),
98+ static function (int $ key , string $ value ): Pair {
99+ /** @phpstan-var non-falsy-string $mappedValue */
100+ $ mappedValue = $ value . '_ ' ;
101+
102+ return new Pair ($ key * 2 , $ mappedValue );
103+ },
97104 );
98105
99106 self ::assertCount (2 , $ map );
@@ -118,14 +125,43 @@ public function testMappedSetsFromIterable(): void
118125
119126 $ map = mappedSetsFromIterable (
120127 $ iterableFactory (),
121- static fn (int $ key , string $ value ) => new Pair ($ key * 2 , $ value . '_ ' ),
128+ static function (int $ key , string $ value ): Pair {
129+ /** @phpstan-var non-falsy-string $mappedValue */
130+ $ mappedValue = $ value . '_ ' ;
131+
132+ return new Pair ($ key * 2 , $ mappedValue );
133+ },
122134 );
123135
124136 self ::assertCount (2 , $ map );
125137 self ::assertTrue ($ map ->get (2 )->contains ('a_ ' , 'b_ ' ));
126138 self ::assertTrue ($ map ->get (4 )->contains ('a_ ' , 'b_ ' ));
127139 }
128140
141+ public function testMappedVectorsFromIterable (): void
142+ {
143+ $ iterableFactory = static function (): Generator {
144+ yield 1 => 'a ' ;
145+ yield 1 => 'b ' ;
146+ yield 2 => 'c ' ;
147+ yield 2 => 'd ' ;
148+ };
149+
150+ $ map = mappedVectorsFromIterable (
151+ $ iterableFactory (),
152+ static function (int $ key , string $ value ): Pair {
153+ /** @phpstan-var non-falsy-string $mappedValue */
154+ $ mappedValue = $ value . '_ ' ;
155+
156+ return new Pair ($ key * 2 , $ mappedValue );
157+ },
158+ );
159+
160+ self ::assertCount (2 , $ map );
161+ self ::assertSame (['a_ ' , 'b_ ' ], $ map ->get (2 )->toArray ());
162+ self ::assertSame (['c_ ' , 'd_ ' ], $ map ->get (4 )->toArray ());
163+ }
164+
129165 public function testSetFromIterable (): void
130166 {
131167 $ iterableFactory = static function (): Generator {
0 commit comments