| @@ 2006-2016 (lines=11) @@ | ||
| 2003 | * @psalm-return static<TKey,T> |
|
| 2004 | * @psalm-mutation-free |
|
| 2005 | */ |
|
| 2006 | public function each(\Closure $closure): self |
|
| 2007 | { |
|
| 2008 | // init |
|
| 2009 | $array = []; |
|
| 2010 | ||
| 2011 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2012 | $array[$key] = $closure($value, $key); |
|
| 2013 | } |
|
| 2014 | ||
| 2015 | return static::create( |
|
| 2016 | $array, |
|
| 2017 | $this->iteratorClass, |
|
| 2018 | false |
|
| 2019 | ); |
|
| @@ 4630-4641 (lines=12) @@ | ||
| 4627 | * @psalm-return static<TKey,T> |
|
| 4628 | * @psalm-mutation-free |
|
| 4629 | */ |
|
| 4630 | public function reject(\Closure $closure): self |
|
| 4631 | { |
|
| 4632 | // init |
|
| 4633 | $filtered = []; |
|
| 4634 | ||
| 4635 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4636 | if (!$closure($value, $key)) { |
|
| 4637 | $filtered[$key] = $value; |
|
| 4638 | } |
|
| 4639 | } |
|
| 4640 | ||
| 4641 | return static::create( |
|
| 4642 | $filtered, |
|
| 4643 | $this->iteratorClass, |
|
| 4644 | false |
|