| @@ 1651-1661 (lines=11) @@ | ||
| 1648 | * @psalm-return static<TKey,T> |
|
| 1649 | * @psalm-mutation-free |
|
| 1650 | */ |
|
| 1651 | public function each(\Closure $closure): self |
|
| 1652 | { |
|
| 1653 | // init |
|
| 1654 | $array = []; |
|
| 1655 | ||
| 1656 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1657 | $array[$key] = $closure($value, $key); |
|
| 1658 | } |
|
| 1659 | ||
| 1660 | return static::create( |
|
| 1661 | $array, |
|
| 1662 | $this->iteratorClass, |
|
| 1663 | false |
|
| 1664 | ); |
|
| @@ 4070-4081 (lines=12) @@ | ||
| 4067 | * @psalm-return static<TKey,T> |
|
| 4068 | * @psalm-mutation-free |
|
| 4069 | */ |
|
| 4070 | public function reject(\Closure $closure): self |
|
| 4071 | { |
|
| 4072 | // init |
|
| 4073 | $filtered = []; |
|
| 4074 | ||
| 4075 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4076 | if (!$closure($value, $key)) { |
|
| 4077 | $filtered[$key] = $value; |
|
| 4078 | } |
|
| 4079 | } |
|
| 4080 | ||
| 4081 | return static::create( |
|
| 4082 | $filtered, |
|
| 4083 | $this->iteratorClass, |
|
| 4084 | false |
|