| @@ 2004-2014 (lines=11) @@ | ||
| 2001 | * @psalm-return static<TKey,T> |
|
| 2002 | * @psalm-mutation-free |
|
| 2003 | */ |
|
| 2004 | public function each(\Closure $closure): self |
|
| 2005 | { |
|
| 2006 | // init |
|
| 2007 | $array = []; |
|
| 2008 | ||
| 2009 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2010 | $array[$key] = $closure($value, $key); |
|
| 2011 | } |
|
| 2012 | ||
| 2013 | return static::create( |
|
| 2014 | $array, |
|
| 2015 | $this->iteratorClass, |
|
| 2016 | false |
|
| 2017 | ); |
|
| @@ 4517-4528 (lines=12) @@ | ||
| 4514 | * @psalm-return static<TKey,T> |
|
| 4515 | * @psalm-mutation-free |
|
| 4516 | */ |
|
| 4517 | public function reject(\Closure $closure): self |
|
| 4518 | { |
|
| 4519 | // init |
|
| 4520 | $filtered = []; |
|
| 4521 | ||
| 4522 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4523 | if (!$closure($value, $key)) { |
|
| 4524 | $filtered[$key] = $value; |
|
| 4525 | } |
|
| 4526 | } |
|
| 4527 | ||
| 4528 | return static::create( |
|
| 4529 | $filtered, |
|
| 4530 | $this->iteratorClass, |
|
| 4531 | false |
|