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