| @@ 2186-2196 (lines=11) @@ | ||
| 2183 | * @psalm-return static<TKey,T> |
|
| 2184 | * @psalm-mutation-free |
|
| 2185 | */ |
|
| 2186 | public function each(\Closure $closure): self |
|
| 2187 | { |
|
| 2188 | // init |
|
| 2189 | $array = []; |
|
| 2190 | ||
| 2191 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2192 | $array[$key] = $closure($value, $key); |
|
| 2193 | } |
|
| 2194 | ||
| 2195 | return static::create( |
|
| 2196 | $array, |
|
| 2197 | $this->iteratorClass, |
|
| 2198 | false |
|
| 2199 | ); |
|
| @@ 5134-5145 (lines=12) @@ | ||
| 5131 | * @psalm-return static<TKey,T> |
|
| 5132 | * @psalm-mutation-free |
|
| 5133 | */ |
|
| 5134 | public function reject(\Closure $closure): self |
|
| 5135 | { |
|
| 5136 | // init |
|
| 5137 | $filtered = []; |
|
| 5138 | ||
| 5139 | foreach ($this->getGenerator() as $key => $value) { |
|
| 5140 | if (!$closure($value, $key)) { |
|
| 5141 | $filtered[$key] = $value; |
|
| 5142 | } |
|
| 5143 | } |
|
| 5144 | ||
| 5145 | return static::create( |
|
| 5146 | $filtered, |
|
| 5147 | $this->iteratorClass, |
|
| 5148 | false |
|