diff --git a/docs/component/arr.md b/docs/component/arr.md
index 55fb7cd..0c4cc9f 100644
--- a/docs/component/arr.md
+++ b/docs/component/arr.md
@@ -41,7 +41,7 @@
- [map](./../../src/Psl/Arr/map.php#L34) ( deprecated )
- [map_keys](./../../src/Psl/Arr/map_keys.php#L34) ( deprecated )
- [map_with_key](./../../src/Psl/Arr/map_with_key.php#L34) ( deprecated )
-- [merge](./../../src/Psl/Arr/merge.php#L32) ( deprecated )
+- [merge](./../../src/Psl/Arr/merge.php#L34) ( deprecated )
- [partition](./../../src/Psl/Arr/partition.php#L22) ( deprecated )
- [random](./../../src/Psl/Arr/random.php#L25) ( deprecated )
- [select_keys](./../../src/Psl/Arr/select_keys.php#L25) ( deprecated )
diff --git a/docs/component/dict.md b/docs/component/dict.md
index 0447be0..de92a8b 100644
--- a/docs/component/dict.md
+++ b/docs/component/dict.md
@@ -34,7 +34,7 @@
- [map](./../../src/Psl/Dict/map.php#L29)
- [map_keys](./../../src/Psl/Dict/map_keys.php#L29)
- [map_with_key](./../../src/Psl/Dict/map_with_key.php#L29)
-- [merge](./../../src/Psl/Dict/merge.php#L19)
+- [merge](./../../src/Psl/Dict/merge.php#L21)
- [partition](./../../src/Psl/Dict/partition.php#L19)
- [partition_with_key](./../../src/Psl/Dict/partition_with_key.php#L19)
- [pull](./../../src/Psl/Dict/pull.php#L35)
diff --git a/docs/component/env.md b/docs/component/env.md
index 369143d..5c83466 100644
--- a/docs/component/env.md
+++ b/docs/component/env.md
@@ -17,7 +17,7 @@
- [current_exec](./../../src/Psl/Env/current_exec.php#L12)
- [get_var](./../../src/Psl/Env/get_var.php#L18)
- [get_vars](./../../src/Psl/Env/get_vars.php#L14)
-- [join_paths](./../../src/Psl/Env/join_paths.php#L16)
+- [join_paths](./../../src/Psl/Env/join_paths.php#L18)
- [remove_var](./../../src/Psl/Env/remove_var.php#L18)
- [set_current_dir](./../../src/Psl/Env/set_current_dir.php#L16)
- [set_var](./../../src/Psl/Env/set_var.php#L19)
diff --git a/docs/component/iter.md b/docs/component/iter.md
index e1084c4..4582f76 100644
--- a/docs/component/iter.md
+++ b/docs/component/iter.md
@@ -43,7 +43,7 @@
- [map](./../../src/Psl/Iter/map.php#L35) ( deprecated )
- [map_keys](./../../src/Psl/Iter/map_keys.php#L35) ( deprecated )
- [map_with_key](./../../src/Psl/Iter/map_with_key.php#L33) ( deprecated )
-- [merge](./../../src/Psl/Iter/merge.php#L30) ( deprecated )
+- [merge](./../../src/Psl/Iter/merge.php#L32) ( deprecated )
- [product](./../../src/Psl/Iter/product.php#L34) ( deprecated )
- [pull](./../../src/Psl/Iter/pull.php#L40) ( deprecated )
- [pull_with_key](./../../src/Psl/Iter/pull_with_key.php#L41) ( deprecated )
diff --git a/psalm.xml b/psalm.xml
index fecab7a..cb7d623 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -59,6 +59,10 @@
+
+
+
+
diff --git a/src/Psl/Arr/first.php b/src/Psl/Arr/first.php
index 115ae9a..1755406 100644
--- a/src/Psl/Arr/first.php
+++ b/src/Psl/Arr/first.php
@@ -24,7 +24,6 @@ use Psl\Iter;
function first(array $array)
{
/**
- * @var Tk|null $first
* @psalm-suppress DeprecatedFunction
*/
$first = first_key($array);
diff --git a/src/Psl/Arr/firstx.php b/src/Psl/Arr/firstx.php
index 848a44a..4b6be68 100644
--- a/src/Psl/Arr/firstx.php
+++ b/src/Psl/Arr/firstx.php
@@ -28,7 +28,6 @@ use Psl\Iter;
function firstx(array $array)
{
/**
- * @var Tk|null $first
* @psalm-suppress DeprecatedFunction
*/
$first = first_key($array);
diff --git a/src/Psl/Arr/last.php b/src/Psl/Arr/last.php
index 9ba3f08..a1e1a6d 100644
--- a/src/Psl/Arr/last.php
+++ b/src/Psl/Arr/last.php
@@ -24,7 +24,6 @@ use Psl\Iter;
function last(array $array)
{
/**
- * @var Tk|null $last
* @psalm-suppress DeprecatedFunction
*/
$last = last_key($array);
diff --git a/src/Psl/Arr/lastx.php b/src/Psl/Arr/lastx.php
index 54c16d0..eae10d7 100644
--- a/src/Psl/Arr/lastx.php
+++ b/src/Psl/Arr/lastx.php
@@ -28,7 +28,6 @@ use Psl\Iter;
function lastx(array $array)
{
/**
- * @var Tk|null $last
* @psalm-suppress DeprecatedFunction
*/
$last = last_key($array);
diff --git a/src/Psl/Arr/merge.php b/src/Psl/Arr/merge.php
index 09ebf49..f6bab6f 100644
--- a/src/Psl/Arr/merge.php
+++ b/src/Psl/Arr/merge.php
@@ -28,6 +28,8 @@ use Psl\Dict;
*
* @deprecated use `Dict\merge` instead.
* @see Dict\merge()
+ *
+ * @no-named-arguments
*/
function merge(iterable $first, iterable ...$rest): array
{
diff --git a/src/Psl/Collection/Map.php b/src/Psl/Collection/Map.php
index c7d4510..fe5dea0 100644
--- a/src/Psl/Collection/Map.php
+++ b/src/Psl/Collection/Map.php
@@ -378,8 +378,6 @@ final class Map implements MapInterface
foreach ($this->elements as $k => $v) {
/**
* @psalm-suppress ImpureFunctionCall - conditionally pure
- *
- * @var Tu|null $u
*/
$u = Iter\first($array);
if (null === $u) {
diff --git a/src/Psl/Collection/MutableMap.php b/src/Psl/Collection/MutableMap.php
index 4ea61df..041a6ad 100644
--- a/src/Psl/Collection/MutableMap.php
+++ b/src/Psl/Collection/MutableMap.php
@@ -372,7 +372,6 @@ final class MutableMap implements MutableMapInterface
foreach ($this->elements as $k => $v) {
/**
- * @var Tu|null $u
* @psalm-suppress ImpureFunctionCall - conditionally pure
*/
$u = Iter\first($array);
diff --git a/src/Psl/DataStructure/PriorityQueue.php b/src/Psl/DataStructure/PriorityQueue.php
index 16f3487..862160d 100644
--- a/src/Psl/DataStructure/PriorityQueue.php
+++ b/src/Psl/DataStructure/PriorityQueue.php
@@ -47,7 +47,6 @@ final class PriorityQueue implements PriorityQueueInterface
return null;
}
- /** @var list $keys */
$keys = Vec\keys($this->queue);
// Retrieve the highest priority.
@@ -133,7 +132,7 @@ final class PriorityQueue implements PriorityQueueInterface
public function count(): int
{
$count = 0;
- foreach ($this->queue as $priority => $list) {
+ foreach ($this->queue as $_priority => $list) {
$count += Iter\count($list);
}
diff --git a/src/Psl/Dict/count_values.php b/src/Psl/Dict/count_values.php
index aeb40ce..23b4daa 100644
--- a/src/Psl/Dict/count_values.php
+++ b/src/Psl/Dict/count_values.php
@@ -29,7 +29,6 @@ function count_values(iterable $values): array
gettype($value)
);
- /** @var int $count */
$count = $result[$value] ?? 0;
/** @var T $value */
$result[$value] = $count + 1;
diff --git a/src/Psl/Dict/filter_with_key.php b/src/Psl/Dict/filter_with_key.php
index 3a5a6e5..c921d33 100644
--- a/src/Psl/Dict/filter_with_key.php
+++ b/src/Psl/Dict/filter_with_key.php
@@ -35,10 +35,10 @@ function filter_with_key(iterable $iterable, ?callable $predicate = null): array
{
$predicate = $predicate ??
/**
- * @param Tk $k
+ * @param Tk $_k
* @param Tv $v
*/
- static fn ($k, $v): bool => Psl\Internal\boolean($v);
+ static fn ($_k, $v): bool => Psl\Internal\boolean($v);
/** @var array $result */
$result = [];
diff --git a/src/Psl/Dict/merge.php b/src/Psl/Dict/merge.php
index e58ef65..d337137 100644
--- a/src/Psl/Dict/merge.php
+++ b/src/Psl/Dict/merge.php
@@ -15,6 +15,8 @@ namespace Psl\Dict;
* @param iterable ...$rest
*
* @return array
+ *
+ * @no-named-arguments
*/
function merge(iterable $first, iterable ...$rest): array
{
diff --git a/src/Psl/Dict/sort_by.php b/src/Psl/Dict/sort_by.php
index 8e30bee..3ec729a 100644
--- a/src/Psl/Dict/sort_by.php
+++ b/src/Psl/Dict/sort_by.php
@@ -45,9 +45,6 @@ function sort_by(iterable $iterable, callable $scalar_func, ?callable $comparato
$tuples[$k] = [$scalar_func($v), $v];
}
- /**
- * @var array $sorted
- */
$sorted = namespace\sort($tuples, $tuple_comparator);
/** @var array $result */
diff --git a/src/Psl/Dict/unique_by.php b/src/Psl/Dict/unique_by.php
index f99d1e9..cbb99b1 100644
--- a/src/Psl/Dict/unique_by.php
+++ b/src/Psl/Dict/unique_by.php
@@ -28,7 +28,6 @@ function unique_by(iterable $iterable, callable $scalar_func): array
$original_values = [];
foreach ($iterable as $k => $v) {
$original_values[$k] = $v;
- /** @var Ts $scalar */
$scalar = $scalar_func($v);
if (!Iter\contains($unique, $scalar)) {
diff --git a/src/Psl/Env/get_var.php b/src/Psl/Env/get_var.php
index a73cd3d..da50b96 100644
--- a/src/Psl/Env/get_var.php
+++ b/src/Psl/Env/get_var.php
@@ -22,7 +22,6 @@ function get_var(string $key): ?string
'Invalid environment variable key provided.'
);
- /** @var false|string $value */
$value = getenv($key);
return false === $value ? null : $value;
diff --git a/src/Psl/Env/join_paths.php b/src/Psl/Env/join_paths.php
index b36bbeb..95018f5 100644
--- a/src/Psl/Env/join_paths.php
+++ b/src/Psl/Env/join_paths.php
@@ -12,6 +12,8 @@ use const PATH_SEPARATOR;
* Joins a collection of paths appropriately for the PATH environment variable.
*
* @param string ...$paths
+ *
+ * @no-named-arguments
*/
function join_paths(string ...$paths): string
{
diff --git a/src/Psl/Hash/Context.php b/src/Psl/Hash/Context.php
index 20b0f18..5612fc7 100644
--- a/src/Psl/Hash/Context.php
+++ b/src/Psl/Hash/Context.php
@@ -87,7 +87,6 @@ final class Context
*/
public function update(string $data): Context
{
- /** @var HashContext $internal_context */
$internal_context = hash_copy($this->internalContext);
hash_update($internal_context, $data);
@@ -101,7 +100,6 @@ final class Context
*/
public function finalize(): string
{
- /** @var HashContext $internal_context */
$internal_context = hash_copy($this->internalContext);
return hash_final($internal_context, false);
diff --git a/src/Psl/Iter/contains_key.php b/src/Psl/Iter/contains_key.php
index 3b779c2..35376d9 100644
--- a/src/Psl/Iter/contains_key.php
+++ b/src/Psl/Iter/contains_key.php
@@ -15,7 +15,7 @@ namespace Psl\Iter;
*/
function contains_key(iterable $iterable, $key): bool
{
- foreach ($iterable as $k => $v) {
+ foreach ($iterable as $k => $_v) {
if ($key === $k) {
return true;
}
diff --git a/src/Psl/Iter/count.php b/src/Psl/Iter/count.php
index 50afd03..8890ae2 100644
--- a/src/Psl/Iter/count.php
+++ b/src/Psl/Iter/count.php
@@ -33,7 +33,6 @@ function count(iterable $iterable): int
}
$count = 0;
- /** @var T $_ */
foreach ($iterable as $_) {
++$count;
}
diff --git a/src/Psl/Iter/filter_with_key.php b/src/Psl/Iter/filter_with_key.php
index d0357bb..d7da7cd 100644
--- a/src/Psl/Iter/filter_with_key.php
+++ b/src/Psl/Iter/filter_with_key.php
@@ -41,12 +41,12 @@ function filter_with_key(iterable $iterable, ?callable $predicate = null): Itera
return Iterator::from(static function () use ($iterable, $predicate): Generator {
$predicate = $predicate ??
/**
- * @param Tk $k
+ * @param Tk $_k
* @param Tv $v
*
* @return bool
*/
- static fn ($k, $v) => Psl\Internal\boolean($v);
+ static fn ($_k, $v) => Psl\Internal\boolean($v);
foreach ($iterable as $k => $v) {
if ($predicate($k, $v)) {
diff --git a/src/Psl/Iter/merge.php b/src/Psl/Iter/merge.php
index 98aa96b..833f093 100644
--- a/src/Psl/Iter/merge.php
+++ b/src/Psl/Iter/merge.php
@@ -26,6 +26,8 @@ use Psl\Dict;
*
* @deprecated use `Dict\merge` instead.
* @see Dict\merge()
+ *
+ * @no-named-arguments
*/
function merge(iterable $first, iterable ...$rest): Iterator
{
diff --git a/src/Psl/Iter/random.php b/src/Psl/Iter/random.php
index deef792..a290766 100644
--- a/src/Psl/Iter/random.php
+++ b/src/Psl/Iter/random.php
@@ -31,7 +31,6 @@ function random(iterable $iterable)
Psl\invariant(0 !== $size, 'Expected a non-empty iterable.');
- /** @var list $shuffled */
$shuffled = Vec\shuffle($values);
if (1 === $size) {
diff --git a/src/Psl/Iter/reduce_keys.php b/src/Psl/Iter/reduce_keys.php
index 76e6aff..6665cc6 100644
--- a/src/Psl/Iter/reduce_keys.php
+++ b/src/Psl/Iter/reduce_keys.php
@@ -33,7 +33,7 @@ namespace Psl\Iter;
function reduce_keys(iterable $iterable, callable $function, $initial = null)
{
$accumulator = $initial;
- foreach ($iterable as $k => $v) {
+ foreach ($iterable as $k => $_v) {
$accumulator = $function($accumulator, $k);
}
diff --git a/src/Psl/Iter/zip.php b/src/Psl/Iter/zip.php
index b23c4e8..369ba09 100644
--- a/src/Psl/Iter/zip.php
+++ b/src/Psl/Iter/zip.php
@@ -42,7 +42,6 @@ function zip(iterable ...$iterables): Iterator
return;
}
- /** @var list> $iterators */
$iterators = Vec\values(Dict\map(
$iterables,
/**
@@ -55,7 +54,6 @@ function zip(iterable ...$iterables): Iterator
apply($iterators, static fn (Iterator $iterator) => $iterator->rewind());
while (all($iterators, static fn (Iterator $iterator) => $iterator->valid())) {
- /** @var list $keys */
$keys = Vec\values(Dict\map(
$iterators,
/**
@@ -66,7 +64,6 @@ function zip(iterable ...$iterables): Iterator
static fn (Iterator $iterator) => $iterator->key(),
));
- /** @var list $values */
$values = Vec\values(Dict\map(
$iterators,
/**
diff --git a/src/Psl/Math/base_convert.php b/src/Psl/Math/base_convert.php
index 7a3114b..cc2eefc 100644
--- a/src/Psl/Math/base_convert.php
+++ b/src/Psl/Math/base_convert.php
@@ -49,15 +49,13 @@ function base_convert(string $value, int $from_base, int $to_base): string
$from_alphabet = Byte\slice(Str\ALPHABET_ALPHANUMERIC, 0, $from_base);
/** @var numeric-string $result_decimal */
$result_decimal = '0';
- /** @var numeric-string $place_value */
$place_value = bcpow((string)$from_base, (string)(Byte\length($value) - 1));
- /** @var string $digit */
foreach (Byte\chunk($value) as $digit) {
+ Psl\invariant(is_numeric($place_value), 'Unexpected error.');
$digit_numeric = Byte\search_ci($from_alphabet, $digit);
Psl\invariant(null !== $digit_numeric, 'Invalid digit %s in base %d', $digit, $from_base);
$result_decimal = bcadd($result_decimal, bcmul((string)$digit_numeric, $place_value));
Psl\invariant(is_numeric($result_decimal), 'Unexpected error.');
- /** @var numeric-string $place_value */
$place_value = bcdiv($place_value, (string)$from_base);
}
diff --git a/src/Psl/Math/from_base.php b/src/Psl/Math/from_base.php
index a7281ad..5e851e2 100644
--- a/src/Psl/Math/from_base.php
+++ b/src/Psl/Math/from_base.php
@@ -36,7 +36,6 @@ function from_base(string $number, int $from_base): int
/** @psalm-suppress MissingThrowsDocblock */
$limit = div(INT64_MAX, $from_base);
$result = 0;
- /** @var string $digit */
foreach (Byte\chunk($number) as $digit) {
$oval = Byte\ord($digit);
// Branches sorted by guesstimated frequency of use. */
diff --git a/src/Psl/Math/maxva.php b/src/Psl/Math/maxva.php
index 8dea56e..21edacb 100644
--- a/src/Psl/Math/maxva.php
+++ b/src/Psl/Math/maxva.php
@@ -22,7 +22,6 @@ function maxva($first, $second, ...$rest)
$max = $first > $second ? $first : $second;
foreach ($rest as $number) {
if ($number > $max) {
- /** @var T $max */
$max = $number;
}
}
diff --git a/src/Psl/Math/median.php b/src/Psl/Math/median.php
index b0e8ed2..01f0ff6 100644
--- a/src/Psl/Math/median.php
+++ b/src/Psl/Math/median.php
@@ -10,13 +10,11 @@ use Psl\Vec;
/**
* Returns the median of the given numbers.
*
- * @pslam-param iterable $numbers
+ * @param iterable $numbers
*/
function median(iterable $numbers): ?float
{
- /** @var list $numbers */
$numbers = Vec\values($numbers);
- /** @var list $numbers */
$numbers = Vec\sort($numbers);
$count = Iter\count($numbers);
if (0 === $count) {
diff --git a/src/Psl/PseudoRandom/float.php b/src/Psl/PseudoRandom/float.php
index ddf63d7..506bc0a 100644
--- a/src/Psl/PseudoRandom/float.php
+++ b/src/Psl/PseudoRandom/float.php
@@ -12,7 +12,6 @@ use Psl\Math;
function float(): float
{
/**
- * @var float|int $result
* @psalm-suppress MissingThrowsDocblock $max is always > than $min
*/
$result = namespace\int(0, Math\INT53_MAX) / Math\INT53_MAX;
diff --git a/src/Psl/SecureRandom/float.php b/src/Psl/SecureRandom/float.php
index 6c64bf8..3fe759b 100644
--- a/src/Psl/SecureRandom/float.php
+++ b/src/Psl/SecureRandom/float.php
@@ -14,7 +14,6 @@ use Psl\Math;
function float(): float
{
/**
- * @var float|int $result
* @psalm-suppress MissingThrowsDocblock
*/
$result = namespace\int(0, Math\INT53_MAX) / Math\INT53_MAX;
diff --git a/src/Psl/Str/chr.php b/src/Psl/Str/chr.php
index 1706128..7e5fedc 100644
--- a/src/Psl/Str/chr.php
+++ b/src/Psl/Str/chr.php
@@ -26,7 +26,6 @@ use function mb_chr;
*/
function chr(int $codepoint, ?string $encoding = null): string
{
- /** @var string|false $char */
$char = mb_chr($codepoint, Internal\internal_encoding($encoding));
/** @psalm-suppress MissingThrowsDocblock */
diff --git a/src/Psl/Type/Internal/IntersectionType.php b/src/Psl/Type/Internal/IntersectionType.php
index e5c40d2..76cb7de 100644
--- a/src/Psl/Type/Internal/IntersectionType.php
+++ b/src/Psl/Type/Internal/IntersectionType.php
@@ -77,7 +77,6 @@ final class IntersectionType extends Type
}
try {
- /** @var Tl $value */
$value = $this->left_type->coerce($value);
/** @var Tl&Tr */
return $this->right_type->assert($value);
@@ -86,7 +85,6 @@ final class IntersectionType extends Type
}
try {
- /** @var Tr $value */
$value = $this->right_type->coerce($value);
/** @var Tr&Tl */
return $this->left_type->assert($value);
@@ -109,7 +107,6 @@ final class IntersectionType extends Type
public function assert($value)
{
try {
- /** @var Tl $value */
$value = $this->left_type->assert($value);
/** @var Tl&Tr */
return $this->right_type->assert($value);
diff --git a/src/Psl/Type/Internal/IterableType.php b/src/Psl/Type/Internal/IterableType.php
index 2ba5a1b..8de0ada 100644
--- a/src/Psl/Type/Internal/IterableType.php
+++ b/src/Psl/Type/Internal/IterableType.php
@@ -90,10 +90,6 @@ final class IterableType extends Type\Type
/** @var iterable */
return Iter\Iterator::from((static function () use ($entries) {
- /**
- * @var Tk $key
- * @var Tv $value
- */
foreach ($entries as [$key, $value]) {
yield $key => $value;
}
@@ -143,10 +139,6 @@ final class IterableType extends Type\Type
/** @var iterable */
return Iter\Iterator::from((static function () use ($entries) {
- /**
- * @var Tk $key
- * @var Tv $value
- */
foreach ($entries as [$key, $value]) {
yield $key => $value;
}
diff --git a/src/Psl/Type/Internal/MutableMapType.php b/src/Psl/Type/Internal/MutableMapType.php
index 8c69bf8..ecafe53 100644
--- a/src/Psl/Type/Internal/MutableMapType.php
+++ b/src/Psl/Type/Internal/MutableMapType.php
@@ -93,7 +93,6 @@ final class MutableMapType extends Type\Type
];
}
- /** @var array $dict */
$dict = Dict\from_entries($entries);
/** @var Collection\MutableMap */
@@ -144,7 +143,6 @@ final class MutableMapType extends Type\Type
];
}
- /** @var array $dict */
$dict = Dict\from_entries($entries);
/** @var Collection\MutableMap */
diff --git a/src/Psl/Vec/filter_with_key.php b/src/Psl/Vec/filter_with_key.php
index b734005..69fcede 100644
--- a/src/Psl/Vec/filter_with_key.php
+++ b/src/Psl/Vec/filter_with_key.php
@@ -35,10 +35,10 @@ function filter_with_key(iterable $iterable, ?callable $predicate = null): array
{
$predicate = $predicate ??
/**
- * @param Tk $k
+ * @param Tk $_k
* @param Tv $v
*/
- static fn ($k, $v): bool => Psl\Internal\boolean($v);
+ static fn ($_k, $v): bool => Psl\Internal\boolean($v);
$result = [];
foreach ($iterable as $k => $v) {
diff --git a/src/Psl/Vec/keys.php b/src/Psl/Vec/keys.php
index eac462c..86001aa 100644
--- a/src/Psl/Vec/keys.php
+++ b/src/Psl/Vec/keys.php
@@ -17,7 +17,7 @@ namespace Psl\Vec;
function keys(iterable $iterable): array
{
$result = [];
- foreach ($iterable as $k => $v) {
+ foreach ($iterable as $k => $_v) {
$result[] = $k;
}