| @@ 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 | ); |
|
| @@ 5152-5163 (lines=12) @@ | ||
| 5149 | * @psalm-return static<TKey,T> |
|
| 5150 | * @psalm-mutation-free |
|
| 5151 | */ |
|
| 5152 | public function reduce($callable, $initial = []): self |
|
| 5153 | { |
|
| 5154 | foreach ($this->getGenerator() as $key => $value) { |
|
| 5155 | $initial = $callable($initial, $value, $key); |
|
| 5156 | } |
|
| 5157 | ||
| 5158 | return static::create( |
|
| 5159 | $initial, |
|
| 5160 | $this->iteratorClass, |
|
| 5161 | false |
|
| 5162 | ); |
|
| 5163 | } |
|
| 5164 | ||
| 5165 | /** |
|
| 5166 | * @param bool $unique |
|
| @@ 5237-5248 (lines=12) @@ | ||
| 5234 | * @psalm-return static<TKey,T> |
|
| 5235 | * @psalm-mutation-free |
|
| 5236 | */ |
|
| 5237 | public function reject(\Closure $closure): self |
|
| 5238 | { |
|
| 5239 | // init |
|
| 5240 | $filtered = []; |
|
| 5241 | ||
| 5242 | foreach ($this->getGenerator() as $key => $value) { |
|
| 5243 | if (!$closure($value, $key)) { |
|
| 5244 | $filtered[$key] = $value; |
|
| 5245 | } |
|
| 5246 | } |
|
| 5247 | ||
| 5248 | return static::create( |
|
| 5249 | $filtered, |
|
| 5250 | $this->iteratorClass, |
|
| 5251 | false |
|