| @@ 2239-2249 (lines=11) @@ | ||
| 2236 | * @psalm-return static<TKey,T> |
|
| 2237 | * @psalm-mutation-free |
|
| 2238 | */ |
|
| 2239 | public function each(\Closure $closure): self |
|
| 2240 | { |
|
| 2241 | // init |
|
| 2242 | $array = []; |
|
| 2243 | ||
| 2244 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2245 | $array[$key] = $closure($value, $key); |
|
| 2246 | } |
|
| 2247 | ||
| 2248 | return static::create( |
|
| 2249 | $array, |
|
| 2250 | $this->iteratorClass, |
|
| 2251 | false |
|
| 2252 | ); |
|
| @@ 5155-5166 (lines=12) @@ | ||
| 5152 | * @psalm-return static<TKey,T> |
|
| 5153 | * @psalm-mutation-free |
|
| 5154 | */ |
|
| 5155 | public function reduce($callable, $initial = []): self |
|
| 5156 | { |
|
| 5157 | foreach ($this->getGenerator() as $key => $value) { |
|
| 5158 | $initial = $callable($initial, $value, $key); |
|
| 5159 | } |
|
| 5160 | ||
| 5161 | return static::create( |
|
| 5162 | $initial, |
|
| 5163 | $this->iteratorClass, |
|
| 5164 | false |
|
| 5165 | ); |
|
| 5166 | } |
|
| 5167 | ||
| 5168 | /** |
|
| 5169 | * @param bool $unique |
|
| @@ 5240-5251 (lines=12) @@ | ||
| 5237 | * @psalm-return static<TKey,T> |
|
| 5238 | * @psalm-mutation-free |
|
| 5239 | */ |
|
| 5240 | public function reject(\Closure $closure): self |
|
| 5241 | { |
|
| 5242 | // init |
|
| 5243 | $filtered = []; |
|
| 5244 | ||
| 5245 | foreach ($this->getGenerator() as $key => $value) { |
|
| 5246 | if (!$closure($value, $key)) { |
|
| 5247 | $filtered[$key] = $value; |
|
| 5248 | } |
|
| 5249 | } |
|
| 5250 | ||
| 5251 | return static::create( |
|
| 5252 | $filtered, |
|
| 5253 | $this->iteratorClass, |
|
| 5254 | false |
|