| @@ 2304-2320 (lines=17) @@ | ||
| 2301 | * @psalm-return static<TKey,T> |
|
| 2302 | * @psalm-mutation-free |
|
| 2303 | */ |
|
| 2304 | public function firstsImmutable(int $number = null): self |
|
| 2305 | { |
|
| 2306 | $arrayTmp = $this->toArray(); |
|
| 2307 | ||
| 2308 | if ($number === null) { |
|
| 2309 | $array = (array) \array_shift($arrayTmp); |
|
| 2310 | } else { |
|
| 2311 | $number = (int) $number; |
|
| 2312 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2313 | } |
|
| 2314 | ||
| 2315 | return static::create( |
|
| 2316 | $array, |
|
| 2317 | $this->iteratorClass, |
|
| 2318 | false |
|
| 2319 | ); |
|
| 2320 | } |
|
| 2321 | ||
| 2322 | /** |
|
| 2323 | * Get the first value(s) from the current array. |
|
| @@ 2334-2350 (lines=17) @@ | ||
| 2331 | * @psalm-return static<TKey,T> |
|
| 2332 | * @psalm-mutation-free |
|
| 2333 | */ |
|
| 2334 | public function firstsKeys(int $number = null): self |
|
| 2335 | { |
|
| 2336 | $arrayTmp = $this->keys()->toArray(); |
|
| 2337 | ||
| 2338 | if ($number === null) { |
|
| 2339 | $array = (array) \array_shift($arrayTmp); |
|
| 2340 | } else { |
|
| 2341 | $number = (int) $number; |
|
| 2342 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2343 | } |
|
| 2344 | ||
| 2345 | return static::create( |
|
| 2346 | $array, |
|
| 2347 | $this->iteratorClass, |
|
| 2348 | false |
|
| 2349 | ); |
|
| 2350 | } |
|
| 2351 | ||
| 2352 | /** |
|
| 2353 | * Get and rmove the first value(s) from the current array. |
|