| @@ 1991-2001 (lines=11) @@ | ||
| 1988 | * @psalm-return static<TKey,T> |
|
| 1989 | * @psalm-mutation-free |
|
| 1990 | */ |
|
| 1991 | public function each(\Closure $closure): self |
|
| 1992 | { |
|
| 1993 | // init |
|
| 1994 | $array = []; |
|
| 1995 | ||
| 1996 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1997 | $array[$key] = $closure($value, $key); |
|
| 1998 | } |
|
| 1999 | ||
| 2000 | return static::create( |
|
| 2001 | $array, |
|
| 2002 | $this->iteratorClass, |
|
| 2003 | false |
|
| 2004 | ); |
|
| @@ 4504-4515 (lines=12) @@ | ||
| 4501 | * @psalm-return static<TKey,T> |
|
| 4502 | * @psalm-mutation-free |
|
| 4503 | */ |
|
| 4504 | public function reject(\Closure $closure): self |
|
| 4505 | { |
|
| 4506 | // init |
|
| 4507 | $filtered = []; |
|
| 4508 | ||
| 4509 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4510 | if (!$closure($value, $key)) { |
|
| 4511 | $filtered[$key] = $value; |
|
| 4512 | } |
|
| 4513 | } |
|
| 4514 | ||
| 4515 | return static::create( |
|
| 4516 | $filtered, |
|
| 4517 | $this->iteratorClass, |
|
| 4518 | false |
|