| @@ 1628-1638 (lines=11) @@ | ||
| 1625 | * |
|
| 1626 | * @psalm-return static<TKey,T> |
|
| 1627 | */ |
|
| 1628 | public function each(\Closure $closure): self |
|
| 1629 | { |
|
| 1630 | // init |
|
| 1631 | $array = []; |
|
| 1632 | ||
| 1633 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1634 | $array[$key] = $closure($value, $key); |
|
| 1635 | } |
|
| 1636 | ||
| 1637 | return static::create( |
|
| 1638 | $array, |
|
| 1639 | $this->iteratorClass, |
|
| 1640 | false |
|
| 1641 | ); |
|
| @@ 4007-4018 (lines=12) @@ | ||
| 4004 | * |
|
| 4005 | * @psalm-return static<TKey,T> |
|
| 4006 | */ |
|
| 4007 | public function reject(\Closure $closure): self |
|
| 4008 | { |
|
| 4009 | // init |
|
| 4010 | $filtered = []; |
|
| 4011 | ||
| 4012 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4013 | if (!$closure($value, $key)) { |
|
| 4014 | $filtered[$key] = $value; |
|
| 4015 | } |
|
| 4016 | } |
|
| 4017 | ||
| 4018 | return static::create( |
|
| 4019 | $filtered, |
|
| 4020 | $this->iteratorClass, |
|
| 4021 | false |
|