| @@ 2149-2159 (lines=11) @@ | ||
| 2146 | * @psalm-return static<TKey,T> |
|
| 2147 | * @psalm-mutation-free |
|
| 2148 | */ |
|
| 2149 | public function each(\Closure $closure): self |
|
| 2150 | { |
|
| 2151 | // init |
|
| 2152 | $array = []; |
|
| 2153 | ||
| 2154 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2155 | $array[$key] = $closure($value, $key); |
|
| 2156 | } |
|
| 2157 | ||
| 2158 | return static::create( |
|
| 2159 | $array, |
|
| 2160 | $this->iteratorClass, |
|
| 2161 | false |
|
| 2162 | ); |
|
| @@ 4862-4873 (lines=12) @@ | ||
| 4859 | * @psalm-return static<TKey,T> |
|
| 4860 | * @psalm-mutation-free |
|
| 4861 | */ |
|
| 4862 | public function reject(\Closure $closure): self |
|
| 4863 | { |
|
| 4864 | // init |
|
| 4865 | $filtered = []; |
|
| 4866 | ||
| 4867 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4868 | if (!$closure($value, $key)) { |
|
| 4869 | $filtered[$key] = $value; |
|
| 4870 | } |
|
| 4871 | } |
|
| 4872 | ||
| 4873 | return static::create( |
|
| 4874 | $filtered, |
|
| 4875 | $this->iteratorClass, |
|
| 4876 | false |
|