|
17 | 17 |
|
18 | 18 | $dataProvider = static function (): Generator { |
19 | 19 | $data = ['foo', 'bar']; |
20 | | - $filter = static function ($value): bool { |
21 | | - return $value === 'bar'; |
22 | | - }; |
| 20 | + $filter = |
| 21 | + /** @param mixed $value */ |
| 22 | + static function ($value): bool { |
| 23 | + return $value === 'bar'; |
| 24 | + }; |
23 | 25 | $map = 'strtoupper'; |
24 | 26 |
|
25 | 27 | yield from [ |
|
50 | 52 | ]; |
51 | 53 | }; |
52 | 54 |
|
53 | | -test('input: array | output: traversable', function ($data, $filter, $map, $expectedResult): void { |
54 | | - $iterableObject = iterable($data, $filter, $map); |
55 | | - assertEquals($expectedResult, iterator_to_array($iterableObject)); |
56 | | -})->with($dataProvider()); |
| 55 | +test( |
| 56 | + 'input: array | output: traversable', |
| 57 | + /** @param array<int, mixed> $data */ |
| 58 | + function (array $data, ?callable $filter, ?callable $map, array $expectedResult): void { |
| 59 | + $iterableObject = iterable($data, $filter, $map); |
| 60 | + assertEquals($expectedResult, iterator_to_array($iterableObject)); |
| 61 | + } |
| 62 | +)->with($dataProvider()); |
57 | 63 |
|
58 | | -test('input: array | output: array', function ($data, $filter, $map, $expectedResult): void { |
59 | | - $iterableObject = iterable($data, $filter, $map); |
60 | | - assertEquals($expectedResult, $iterableObject->asArray()); |
61 | | -})->with($dataProvider()); |
| 64 | +test( |
| 65 | + 'input: array | output: array', |
| 66 | + /** @param array<int, mixed> $data */ |
| 67 | + function (array $data, ?callable $filter, ?callable $map, array $expectedResult): void { |
| 68 | + $iterableObject = iterable($data, $filter, $map); |
| 69 | + assertEquals($expectedResult, $iterableObject->asArray()); |
| 70 | + } |
| 71 | +)->with($dataProvider()); |
62 | 72 |
|
63 | | -test('input: traversable | output: traversable', function ($data, $filter, $map, $expectedResult): void { |
64 | | - $data = SplFixedArray::fromArray($data); |
65 | | - $iterableObject = iterable($data, $filter, $map); |
66 | | - assertEquals($expectedResult, iterator_to_array($iterableObject)); |
67 | | -})->with($dataProvider()); |
| 73 | +test( |
| 74 | + 'input: traversable | output: traversable', |
| 75 | + /** @param array<int, mixed> $data */ |
| 76 | + function (array $data, ?callable $filter, ?callable $map, array $expectedResult): void { |
| 77 | + $data = SplFixedArray::fromArray($data); |
| 78 | + $iterableObject = iterable($data, $filter, $map); |
| 79 | + assertEquals($expectedResult, iterator_to_array($iterableObject)); |
| 80 | + } |
| 81 | +)->with($dataProvider()); |
68 | 82 |
|
69 | | -test('input: traversable | output: array', function ($data, $filter, $map, $expectedResult): void { |
70 | | - $data = SplFixedArray::fromArray($data); |
71 | | - $iterableObject = iterable($data, $filter, $map); |
72 | | - assertEquals($expectedResult, $iterableObject->asArray()); |
73 | | -})->with($dataProvider()); |
| 83 | +test( |
| 84 | + 'input: traversable | output: array', |
| 85 | + /** @param array<int, mixed> $data */ |
| 86 | + function (array $data, ?callable $filter, ?callable $map, array $expectedResult): void { |
| 87 | + $data = SplFixedArray::fromArray($data); |
| 88 | + $iterableObject = iterable($data, $filter, $map); |
| 89 | + assertEquals($expectedResult, $iterableObject->asArray()); |
| 90 | + } |
| 91 | +)->with($dataProvider()); |
74 | 92 |
|
75 | 93 | it('filters the subject', function (): void { |
76 | | - $filter = static function ($value): bool { |
77 | | - return $value === 'bar'; |
78 | | - }; |
| 94 | + $filter = |
| 95 | + /** @param mixed $value */ |
| 96 | + static function ($value): bool { |
| 97 | + return $value === 'bar'; |
| 98 | + }; |
79 | 99 | $iterableObject = iterable(['foo', 'bar'])->filter($filter); |
80 | 100 | assertEquals([1 => 'bar'], iterator_to_array($iterableObject)); |
81 | 101 | }); |
|
88 | 108 | }); |
89 | 109 |
|
90 | 110 | it('combines filter and map', function (): void { |
91 | | - $filter = static function ($value): bool { |
92 | | - return $value === 'bar'; |
93 | | - }; |
| 111 | + $filter = |
| 112 | + /** @param mixed $value */ |
| 113 | + static function ($value): bool { |
| 114 | + return $value === 'bar'; |
| 115 | + }; |
94 | 116 | $map = 'strtoupper'; |
95 | 117 | $iterableObject = iterable(['foo', 'bar'])->map($map)->filter($filter); |
96 | 118 | assertInstanceOf(IterableObject::class, $iterableObject); |
|
0 commit comments