| @@ 2014-2024 (lines=11) @@ | ||
| 2011 | * @psalm-return static<TKey,T> |
|
| 2012 | * @psalm-mutation-free |
|
| 2013 | */ |
|
| 2014 | public function each(\Closure $closure): self |
|
| 2015 | { |
|
| 2016 | // init |
|
| 2017 | $array = []; |
|
| 2018 | ||
| 2019 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2020 | $array[$key] = $closure($value, $key); |
|
| 2021 | } |
|
| 2022 | ||
| 2023 | return static::create( |
|
| 2024 | $array, |
|
| 2025 | $this->iteratorClass, |
|
| 2026 | false |
|
| 2027 | ); |
|
| @@ 4593-4604 (lines=12) @@ | ||
| 4590 | * @psalm-return static<TKey,T> |
|
| 4591 | * @psalm-mutation-free |
|
| 4592 | */ |
|
| 4593 | public function reject(\Closure $closure): self |
|
| 4594 | { |
|
| 4595 | // init |
|
| 4596 | $filtered = []; |
|
| 4597 | ||
| 4598 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4599 | if (!$closure($value, $key)) { |
|
| 4600 | $filtered[$key] = $value; |
|
| 4601 | } |
|
| 4602 | } |
|
| 4603 | ||
| 4604 | return static::create( |
|
| 4605 | $filtered, |
|
| 4606 | $this->iteratorClass, |
|
| 4607 | false |
|