Add sequence helper

This commit is contained in:
azjezz 2020-02-22 17:27:31 +01:00
parent 8ea3a8de27
commit 871c4a186b
2 changed files with 21 additions and 7 deletions

19
src/Psl/sequence.php Normal file
View File

@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Psl;
/**
* This function is a kludge that returns the last argument it receives.
*
* @psalm-template T
*
* @psalm-param T ...$args
*
* @psalm-return null|T
*/
function sequence(...$args)
{
return Iter\last($args);
}

View File

@ -16,6 +16,7 @@ function __bootstrap(): void
'/Psl/Random/float.php',
'/Psl/Random/bytes.php',
'/Psl/internal.php',
'/Psl/sequence.php',
'/Psl/Str/replace_every_ci.php',
'/Psl/Str/ends_with_ci.php',
'/Psl/Str/pad_left.php',
@ -129,7 +130,6 @@ function __bootstrap(): void
'/Psl/Math/constants.php',
'/Psl/Math/min_by.php',
'/Psl/invariant.php',
'/Psl/Iter/pull.php',
'/Psl/Iter/count.php',
'/Psl/Iter/values.php',
@ -245,7 +245,6 @@ function __bootstrap(): void
'/Psl/Arr/count_values.php',
'/Psl/Arr/merge.php',
'/Psl/Arr/shuffle.php',
'/bootstrap.php',
];
if ($booted) {
@ -254,11 +253,7 @@ function __bootstrap(): void
$booted = true;
foreach ($files as $file) {
if (!\file_exists(__DIR__.'/'.$file)) {
\var_dump($file);
} else {
require_once __DIR__ . '/' . $file;
}
require_once __DIR__ . '/' . $file;
}
}