| @@ 2319-2335 (lines=17) @@ | ||
| 2316 | * @psalm-return static<TKey,T> |
|
| 2317 | * @psalm-mutation-free |
|
| 2318 | */ |
|
| 2319 | public function firstsImmutable(int $number = null): self |
|
| 2320 | { |
|
| 2321 | $arrayTmp = $this->toArray(); |
|
| 2322 | ||
| 2323 | if ($number === null) { |
|
| 2324 | $array = (array) \array_shift($arrayTmp); |
|
| 2325 | } else { |
|
| 2326 | $number = (int) $number; |
|
| 2327 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2328 | } |
|
| 2329 | ||
| 2330 | return static::create( |
|
| 2331 | $array, |
|
| 2332 | $this->iteratorClass, |
|
| 2333 | false |
|
| 2334 | ); |
|
| 2335 | } |
|
| 2336 | ||
| 2337 | /** |
|
| 2338 | * Get the first value(s) from the current array. |
|
| @@ 2349-2365 (lines=17) @@ | ||
| 2346 | * @psalm-return static<TKey,T> |
|
| 2347 | * @psalm-mutation-free |
|
| 2348 | */ |
|
| 2349 | public function firstsKeys(int $number = null): self |
|
| 2350 | { |
|
| 2351 | $arrayTmp = $this->keys()->toArray(); |
|
| 2352 | ||
| 2353 | if ($number === null) { |
|
| 2354 | $array = (array) \array_shift($arrayTmp); |
|
| 2355 | } else { |
|
| 2356 | $number = (int) $number; |
|
| 2357 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2358 | } |
|
| 2359 | ||
| 2360 | return static::create( |
|
| 2361 | $array, |
|
| 2362 | $this->iteratorClass, |
|
| 2363 | false |
|
| 2364 | ); |
|
| 2365 | } |
|
| 2366 | ||
| 2367 | /** |
|
| 2368 | * Get and rmove the first value(s) from the current array. |
|