Skip to content

Commit

Permalink
fix: update various operations static analysis annotations.
Browse files Browse the repository at this point in the history
Get rid of a couple of Psalm issues
  • Loading branch information
drupol committed Nov 7, 2022
1 parent bde565c commit 2fb44cf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 29 deletions.
20 changes: 2 additions & 18 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.29.0@7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3">
<files psalm-version="4.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69">
<file src="src/Collection.php">
<InvalidArgument occurrences="5">
<code>$callback</code>
<InvalidArgument occurrences="4">
<code>$callback</code>
<code>$callback</code>
<code>$callback</code>
Expand All @@ -14,28 +13,13 @@
<InvalidReturnType occurrences="1">
<code>CollectionInterface</code>
</InvalidReturnType>
<LessSpecificReturnStatement occurrences="1">
<code>new self((new Zip())()(...$iterables), [$this])</code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType occurrences="1">
<code>CollectionInterface</code>
</MoreSpecificReturnType>
<PossiblyInvalidArgument occurrences="2">
<code>$callbackForKeys ?? $defaultCallback</code>
<code>$callbackForValues ?? $defaultCallback</code>
</PossiblyInvalidArgument>
</file>
<file src="src/Operation/All.php">
<InvalidReturnStatement occurrences="1"/>
<InvalidReturnType occurrences="1">
<code>Closure(bool): Closure(iterable&lt;TKey, T&gt;): (Generator&lt;int, T&gt;|Generator&lt;TKey, T&gt;)</code>
</InvalidReturnType>
</file>
<file src="src/Operation/Averages.php">
<InvalidScalarArgument occurrences="1">
<code>static fn (float $acc, float $value, int $key): float =&gt; ($acc * $key + $value) / ($key + 1)</code>
</InvalidScalarArgument>
</file>
<file src="src/Operation/Inits.php">
<InvalidArgument occurrences="2">
<code>[]</code>
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/FoldLeft1.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ final class FoldLeft1 extends AbstractOperation
/**
* @template V
*
* @return Closure(callable(T|V, T, TKey, iterable<TKey, T>): V): Closure(iterable<TKey, T>): Generator<int|TKey, T|V|null>
* @return Closure(callable(T|V, T, TKey, iterable<TKey, T>): (T|V)): Closure(iterable<TKey, T>): Generator<int|TKey, T|V|null>
*/
public function __invoke(): Closure
{
return
/**
* @param callable(T|V, T, TKey, iterable<TKey, T>): V $callback
* @param callable(T|V, T, TKey, iterable<TKey, T>): (T|V) $callback
*
* @return Closure(iterable<TKey, T>): Generator<int|TKey, T|V|null>
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/FoldRight1.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ final class FoldRight1 extends AbstractOperation
/**
* @template V
*
* @return Closure(callable(T|V, T, TKey, iterable<TKey, T>): V): Closure(iterable<TKey, T>): Generator<int|TKey, T|V|null>
* @return Closure(callable(T|V, T, TKey, iterable<TKey, T>): (T|V)): Closure(iterable<TKey, T>): Generator<int|TKey, T|V|null>
*/
public function __invoke(): Closure
{
return
/**
* @param callable(T|V, T, TKey, iterable<TKey, T>): V $callback
* @param callable(T|V, T, TKey, iterable<TKey, T>): (T|V) $callback
*
* @return Closure(iterable<TKey, T>): Generator<int|TKey, T|V|null>
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/ScanLeft1.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ final class ScanLeft1 extends AbstractOperation
/**
* @template V
*
* @return Closure(callable(T|V, T, TKey, iterable<TKey, T>): V): Closure(iterable<TKey, T>): Generator<int|TKey, T|V>
* @return Closure(callable(T|V, T, TKey, iterable<TKey, T>): (T|V)): Closure(iterable<TKey, T>): Generator<int|TKey, T|V>
*/
public function __invoke(): Closure
{
return
/**
* @param callable(T|V, T, TKey, iterable<TKey, T>): V $callback
* @param callable(T|V, T, TKey, iterable<TKey, T>): (T|V) $callback
*
* @return Closure(iterable<TKey, T>): Generator<int|TKey, T|V>
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/ScanRight1.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ final class ScanRight1 extends AbstractOperation
/**
* @template V
*
* @return Closure(callable(T|V, T, TKey, iterable<TKey, T>): V): Closure(iterable<TKey, T>): Generator<int|TKey, T|V>
* @return Closure(callable(T|V, T, TKey, iterable<TKey, T>): (T|V)): Closure(iterable<TKey, T>): Generator<int|TKey, T|V>
*/
public function __invoke(): Closure
{
return
/**
* @param callable(T|V, T, TKey, iterable<TKey, T>): V $callback
* @param callable(T|V, T, TKey, iterable<TKey, T>): (T|V) $callback
*
* @return Closure(iterable<TKey, T>): Generator<int|TKey, T|V>
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Operation/Zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ final class Zip extends AbstractOperation
* @template UKey
* @template U
*
* @return Closure(iterable<UKey, U>...): Closure(iterable<TKey, T>): Generator<array<int, TKey|UKey|null>, array<int, T|U|null>>
* @return Closure(iterable<UKey, U>...): Closure(iterable<TKey, T>): Generator<list<TKey|UKey|null>, list<T|U|null>>
*/
public function __invoke(): Closure
{
return
/**
* @param iterable<UKey, U> ...$iterables
*
* @return Closure(iterable<TKey, T>): Generator<array<int, TKey|UKey|null>, array<int, T|U|null>>
* @return Closure(iterable<TKey, T>): Generator<list<TKey|UKey|null>, list<T|U|null>>
*/
static fn (iterable ...$iterables): Closure =>
/**
* @param iterable<TKey, T> $iterable
*
* @return Generator<array<int, TKey|UKey|null>, array<int, T|U|null>>
* @return Generator<list<TKey|UKey|null>, list<T|U|null>>
*/
static fn (iterable $iterable): Generator => yield from new MultipleIterableAggregate([$iterable, ...array_values($iterables)], MultipleIterator::MIT_NEED_ANY);
}
Expand Down

0 comments on commit 2fb44cf

Please sign in to comment.