| @@ 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 | ); |
|
| @@ 5150-5161 (lines=12) @@ | ||
| 5147 | * @psalm-return static<TKey,T> |
|
| 5148 | * @psalm-mutation-free |
|
| 5149 | */ |
|
| 5150 | public function reject(\Closure $closure): self |
|
| 5151 | { |
|
| 5152 | // init |
|
| 5153 | $filtered = []; |
|
| 5154 | ||
| 5155 | foreach ($this->getGenerator() as $key => $value) { |
|
| 5156 | if (!$closure($value, $key)) { |
|
| 5157 | $filtered[$key] = $value; |
|
| 5158 | } |
|
| 5159 | } |
|
| 5160 | ||
| 5161 | return static::create( |
|
| 5162 | $filtered, |
|
| 5163 | $this->iteratorClass, |
|
| 5164 | false |
|