| @@ 1875-1885 (lines=11) @@ | ||
| 1872 | * @psalm-return static<TKey,T> |
|
| 1873 | * @psalm-mutation-free |
|
| 1874 | */ |
|
| 1875 | public function each(\Closure $closure): self |
|
| 1876 | { |
|
| 1877 | // init |
|
| 1878 | $array = []; |
|
| 1879 | ||
| 1880 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1881 | $array[$key] = $closure($value, $key); |
|
| 1882 | } |
|
| 1883 | ||
| 1884 | return static::create( |
|
| 1885 | $array, |
|
| 1886 | $this->iteratorClass, |
|
| 1887 | false |
|
| 1888 | ); |
|
| @@ 4366-4377 (lines=12) @@ | ||
| 4363 | * @psalm-return static<TKey,T> |
|
| 4364 | * @psalm-mutation-free |
|
| 4365 | */ |
|
| 4366 | public function reject(\Closure $closure): self |
|
| 4367 | { |
|
| 4368 | // init |
|
| 4369 | $filtered = []; |
|
| 4370 | ||
| 4371 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4372 | if (!$closure($value, $key)) { |
|
| 4373 | $filtered[$key] = $value; |
|
| 4374 | } |
|
| 4375 | } |
|
| 4376 | ||
| 4377 | return static::create( |
|
| 4378 | $filtered, |
|
| 4379 | $this->iteratorClass, |
|
| 4380 | false |
|