fix typing issues (#23)

This commit is contained in:
Saif Eddin G 2020-07-07 19:04:05 +02:00 committed by GitHub
parent c3d0cdc062
commit e8dba9dc81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 4 deletions

View File

@ -52,6 +52,10 @@ function sort_with_keys_by(iterable $iterable, callable $scalar_func, ?callable
);
$sorted = sort_with_keys($tuples, $tuple_comparator);
/**
* @psalm-suppress InvalidArgument
* @psalm-suppress MixedArgumentTypeCoercion
*/
$result = Iter\map_with_key(
$sorted,
/**

View File

@ -30,7 +30,7 @@ interface IMutableVector extends IVector, IMutableAccessibleCollection
/**
* Returns a `IMutableVector` containing the keys of the current `IMutableVector`.
*
* @psalm-return IMutableVector<T>
* @psalm-return IMutableVector<int>
*/
public function keys(): IMutableVector;

View File

@ -305,7 +305,10 @@ final class MutableVector implements IMutableVector
*/
public function keys(): MutableVector
{
return new MutableVector(Arr\keys($this->elements));
/** @psalm-var list<int> $keys */
$keys = Arr\keys($this->elements);
return new MutableVector($keys);
}
/**

View File

@ -11,5 +11,8 @@ use Psl\Math;
*/
function float(): float
{
return (float) int(0, Math\INT53_MAX) / Math\INT53_MAX;
/** @var float|int $result */
$result = int(0, Math\INT53_MAX) / Math\INT53_MAX;
return (float) $result;
}

View File

@ -30,7 +30,7 @@ function string(int $length, ?string $alphabet = null): string
$ret = '';
while ($length > 0) {
$urandom_length = (int) Math\ceil(2 * $length * $bits / 8.0);
$urandom_length = (int) Math\ceil((float) (2 * $length * $bits) / 8.0);
$data = bytes($urandom_length);
$unpacked_data = 0;
$unpacked_bits = 0;