Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psalm 5.4 upgrade #287

Merged
merged 50 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
700d009
fix `append`
drupol Jan 7, 2023
d1fb1ef
fix `apply`
drupol Dec 22, 2022
9adaac3
fix `associate`
drupol Dec 26, 2022
3ebba89
fix `asyncMap`
drupol Dec 26, 2022
5a4c2c6
fix `compare`
drupol Jan 2, 2023
17ecf05
Fix `current`
drupol Jan 2, 2023
9e5bf8f
fix `diff`
drupol Dec 22, 2022
6dabcb4
fix `distinct`
drupol Dec 26, 2022
e4c6236
fix `drop`
drupol Dec 22, 2022
9c181fd
fix `find`
drupol Jan 2, 2023
962e0dc
fix `filter`
drupol Dec 26, 2022
b649d40
fix `first`
drupol Jan 8, 2023
bf8ce44
fix `flip`
drupol Jan 2, 2023
89a0d6c
fix `fromCallable`
drupol Dec 26, 2022
edd201d
fix `fromGenerator`
drupol Dec 26, 2022
79212b7
fix `fromIterable`
drupol Dec 26, 2022
8d7ec97
Fix `get`
drupol Jan 2, 2023
255d983
fix `groupby`
drupol Dec 26, 2022
f31ae20
Fix `head`
drupol Jan 2, 2023
8cbe9b6
fix `inits`
drupol Jan 2, 2023
453c4ae
Fix `key`
drupol Jan 2, 2023
cb5724a
fix `keys`
drupol Dec 26, 2022
fe71a6f
fix `last`
drupol Jan 2, 2023
029bcb5
fix `map`
drupol Dec 22, 2022
576937c
fix `matching`
drupol Dec 26, 2022
96ac70d
fix `max`
drupol Jan 2, 2023
84abfb4
fix `min`
drupol Dec 28, 2022
319081b
fix `pack`
drupol Jan 2, 2023
327d79e
fix `prepend`
drupol Jan 3, 2023
1a9416a
fix `product`
drupol Dec 26, 2022
53b35e6
fix `random`
drupol Jan 2, 2023
ccea8b6
fix `reduction`
drupol Dec 22, 2022
316b4fb
fix `reject`
drupol Dec 26, 2022
232bc74
fix `reverse`
drupol Dec 22, 2022
04049c7
fix `scanLeft1`
drupol Dec 26, 2022
c6fee2f
fix `scanRight1`
drupol Dec 26, 2022
497e96a
fix `shuffle`
drupol Jan 2, 2023
56074b0
fix `span`
drupol Dec 26, 2022
cdd1005
fix `squash`
drupol Dec 26, 2022
6e12d97
fix `strict`
drupol Dec 26, 2022
27e073e
fix `tail`
drupol Dec 26, 2022
d0d685e
fix `unfold`
drupol Dec 22, 2022
06f14dd
fix `unpack`
drupol Jan 2, 2023
92a8c94
fix `when`
drupol Dec 26, 2022
444f917
fix `window`
drupol Dec 22, 2022
0e54533
fix `wrap`
drupol Jan 2, 2023
c8c2741
fix `zip`
drupol Jan 2, 2023
758a8a2
sa: Update `psalm` baseline
drupol Jan 2, 2023
1814fc3
sa: Update `phpstan` baseline
drupol Jan 7, 2023
f355cb3
chore: update `psalm` to commit f723e08221c5028612d928241c84d9cac7fe6d86
drupol Jan 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
],
"require": {
"php": ">= 8",
"loophp/iterators": "^2.3.1"
"loophp/iterators": "^2.3.1",
"vimeo/psalm": "dev-master#f723e08221c5028612d928241c84d9cac7fe6d86"
},
"require-dev": {
"amphp/parallel-functions": "^1",
Expand Down
31 changes: 28 additions & 3 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ parameters:
count: 1
path: src/Collection.php

-
message: "#^Method loophp\\\\collection\\\\Collection\\:\\:squash\\(\\) should return loophp\\\\collection\\\\Contract\\\\Collection\\<TKey, T\\> but returns loophp\\\\collection\\\\Contract\\\\Collection\\<int, array\\{TKey, T\\}\\>\\.$#"
count: 1
path: src/Collection.php

-
message: "#^Method loophp\\\\collection\\\\Collection\\:\\:tails\\(\\) should return loophp\\\\collection\\\\Contract\\\\Collection\\<int, array\\<int, T\\>\\> but returns loophp\\\\collection\\\\Collection\\<int, array\\<int, mixed\\>\\>\\.$#"
count: 1
Expand All @@ -41,7 +46,7 @@ parameters:
path: src/Collection.php

-
message: "#^Method loophp\\\\collection\\\\Collection\\:\\:wrap\\(\\) should return loophp\\\\collection\\\\Contract\\\\Collection\\<int, array\\<\\(int&TKey\\)\\|\\(string&TKey\\), T\\>\\> but returns loophp\\\\collection\\\\Collection\\<int, array\\>\\.$#"
message: "#^Method loophp\\\\collection\\\\Collection\\:\\:wrap\\(\\) should return loophp\\\\collection\\\\Contract\\\\Collection\\<int, array\\<\\(int&TKey\\)\\|\\(string&TKey\\), T\\>\\> but returns loophp\\\\collection\\\\Collection\\<int, array\\<int\\|string, mixed\\>\\>\\.$#"
count: 1
path: src/Collection.php

Expand All @@ -57,7 +62,7 @@ parameters:

-
message: "#^Parameter \\#1 \\$callable of class loophp\\\\collection\\\\Collection constructor expects callable\\(\\.\\.\\.mixed\\)\\: iterable, Closure\\(iterable\\)\\: Generator\\<mixed, mixed, mixed, mixed\\> given\\.$#"
count: 14
count: 13
path: src/Collection.php

-
Expand All @@ -70,6 +75,11 @@ parameters:
count: 1
path: src/Collection.php

-
message: "#^Parameter \\#1 \\$callable of class loophp\\\\collection\\\\Collection constructor expects callable\\(\\.\\.\\.mixed\\)\\: iterable, Closure\\(iterable\\<array\\{mixed, mixed\\}\\>\\)\\: Generator\\<mixed, mixed, mixed, mixed\\> given\\.$#"
count: 1
path: src/Collection.php

-
message: "#^Parameter \\#1 \\$callable of class loophp\\\\collection\\\\Collection constructor expects callable\\(\\.\\.\\.mixed\\)\\: iterable\\<array\\<int, mixed\\>\\>, Closure\\(iterable\\)\\: Generator\\<mixed, array\\<int, mixed\\>, mixed, mixed\\> given\\.$#"
count: 1
Expand All @@ -96,7 +106,7 @@ parameters:
path: src/Collection.php

-
message: "#^Parameter \\#1 \\$callable of class loophp\\\\collection\\\\Collection constructor expects callable\\(\\.\\.\\.mixed\\)\\: iterable\\<int, array\\>, Closure\\(iterable\\)\\: Generator\\<int, array, mixed, mixed\\> given\\.$#"
message: "#^Parameter \\#1 \\$callable of class loophp\\\\collection\\\\Collection constructor expects callable\\(\\.\\.\\.mixed\\)\\: iterable\\<int, array\\<int\\|string, mixed\\>\\>, Closure\\(iterable\\)\\: Generator\\<int, array\\<int\\|string, mixed\\>, mixed, mixed\\> given\\.$#"
count: 1
path: src/Collection.php

Expand Down Expand Up @@ -150,6 +160,11 @@ parameters:
count: 1
path: src/CollectionDecorator.php

-
message: "#^Template type U of method loophp\\\\collection\\\\Operation\\\\Append\\:\\:__invoke\\(\\) is not referenced in a parameter\\.$#"
count: 1
path: src/Operation/Append.php

-
message: "#^Template type NewT of method loophp\\\\collection\\\\Operation\\\\Associate\\:\\:__invoke\\(\\) is not referenced in a parameter\\.$#"
count: 1
Expand Down Expand Up @@ -240,6 +255,11 @@ parameters:
count: 1
path: src/Operation/Map.php

-
message: "#^Template type U of method loophp\\\\collection\\\\Operation\\\\Prepend\\:\\:__invoke\\(\\) is not referenced in a parameter\\.$#"
count: 1
path: src/Operation/Prepend.php

-
message: "#^Template type U of method loophp\\\\collection\\\\Operation\\\\Product\\:\\:__invoke\\(\\) is not referenced in a parameter\\.$#"
count: 1
Expand Down Expand Up @@ -314,3 +334,8 @@ parameters:
message: "#^While loop condition is always true\\.$#"
count: 1
path: tests/static-analysis/scanRight1.php

-
message: "#^Parameter \\#1 \\$collection of function unfold_checkList expects loophp\\\\collection\\\\Contract\\\\Collection\\<int, iterable\\>, loophp\\\\collection\\\\Contract\\\\Collection\\<int, iterable\\<\\(int\\|string\\), mixed\\>\\> given\\.$#"
count: 3
path: tests/static-analysis/unfold.php
70 changes: 42 additions & 28 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,58 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69">
<files psalm-version="dev-master@c6cfa86f35350842d00e8f1f3b92839fbda5f8f9">
<file src="src/Collection.php">
<InvalidArgument occurrences="1">
<InvalidArgument>
<code>$callback</code>
<code>$parameters</code>
</InvalidArgument>
<InvalidReturnStatement occurrences="1">
<InvalidReturnStatement>
<code>new self((new Operation\Unfold())()($parameters)($callback))</code>
<code>new self((new Operation\Wrap())(), [$this])</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<InvalidReturnType>
<code>CollectionInterface</code>
<code>CollectionInterface</code>
</InvalidReturnType>
<PossiblyNullArgument occurrences="2">
<PossiblyNullArgument>
<code>$default</code>
<code>$default</code>
</PossiblyNullArgument>
</file>
<file src="src/CollectionDecorator.php">
<InvalidArgument occurrences="4">
<InvalidArgument>
<code>foldLeft1</code>
<code>foldRight1</code>
<code>scanLeft1</code>
<code>scanRight1</code>
</InvalidArgument>
<InvalidReturnType occurrences="8">
<code>array</code>
<code>static</code>
<code>static</code>
<code>static</code>
<code>static</code>
<code>static</code>
<code>static</code>
<InvalidReturnType>
<code>static</code>
</InvalidReturnType>
</file>
<file src="src/Operation/All.php">
<InvalidReturnStatement occurrences="1"/>
<InvalidReturnType occurrences="1">
<InvalidReturnStatement>
<code>static fn (bool $normalize): Closure =&gt;
/**
* @param iterable&lt;TKey, T&gt; $iterable
*
* @return Generator&lt;int, T&gt;|Generator&lt;TKey, T&gt;
*/
static fn (iterable $iterable): Generator =&gt; yield from ($normalize ? (new Normalize())()($iterable) : $iterable)</code>
</InvalidReturnStatement>
<InvalidReturnType>
<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/Inits.php">
<InvalidArgument occurrences="2">
<code>[]</code>
</InvalidArgument>
</file>
<file src="src/Operation/Pack.php">
<InvalidReturnType occurrences="1">
<code>Generator&lt;int, array{0: TKey, 1: T}&gt;</code>
</InvalidReturnType>
<file src="src/Operation/Pluck.php">
<ArgumentTypeCoercion>
<code>$segment</code>
</ArgumentTypeCoercion>
</file>
<file src="src/Operation/Product.php">
<InvalidArgument occurrences="2">
<InvalidArgument>
<code>[[]]</code>
<code>static fn (iterable $a, iterable $x): Generator =&gt; $f($x)($a)</code>
</InvalidArgument>
</file>
<file src="src/Operation/Zip.php">
<MoreSpecificReturnType>
<code>Generator&lt;list&lt;TKey|UKey|null&gt;, list&lt;T|U|null&gt;&gt;</code>
</MoreSpecificReturnType>
</file>
<file src="tests/static-analysis/partition.php">
<PossiblyUndefinedArrayOffset>
<code>$left</code>
<code>$left</code>
</PossiblyUndefinedArrayOffset>
</file>
<file src="tests/static-analysis/span.php">
<PossiblyUndefinedArrayOffset>
<code>$left</code>
<code>$left</code>
</PossiblyUndefinedArrayOffset>
</file>
</files>
20 changes: 10 additions & 10 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function compact(mixed ...$values): CollectionInterface
return new self((new Operation\Compact())()($values), [$this]);
}

public function compare(callable $comparator, $default = null): mixed
public function compare(callable $comparator, $default = null)
{
return (new self((new Operation\Compare())()($comparator), [$this]))->current(0, $default);
}
Expand All @@ -142,7 +142,7 @@ public function count(): int
return iterator_count($this);
}

public function current(int $index = 0, $default = null): mixed
public function current(int $index = 0, $default = null)
{
return (new Operation\Current())()($index)($default)($this)->current();
}
Expand Down Expand Up @@ -266,12 +266,12 @@ public function filter(callable ...$callbacks): CollectionInterface
return new self((new Operation\Filter())()(...$callbacks), [$this]);
}

public function find(mixed $default = null, callable ...$callbacks): mixed
public function find(mixed $default = null, callable ...$callbacks)
{
return (new Operation\Find())()($default)(...$callbacks)($this)->current();
}

public function first(mixed $default = null): mixed
public function first(mixed $default = null)
{
return (new self((new Operation\First())(), [$this]))->current(0, $default);
}
Expand Down Expand Up @@ -389,7 +389,7 @@ public static function fromString(string $string, string $delimiter = ''): Colle
return new self(static fn (): Generator => yield from new StringIteratorAggregate($string, $delimiter));
}

public function get(mixed $key, mixed $default = null): mixed
public function get(mixed $key, mixed $default = null)
{
return (new self((new Operation\Get())()($key)($default), [$this]))->current(0, $default);
}
Expand Down Expand Up @@ -417,7 +417,7 @@ public function has(callable ...$callbacks): bool
return (new Operation\Has())()(...$callbacks)($this)->current();
}

public function head(mixed $default = null): mixed
public function head(mixed $default = null)
{
return (new self((new Operation\Head())(), [$this]))->current(0, $default);
}
Expand Down Expand Up @@ -483,7 +483,7 @@ public function jsonSerialize(): array
return $this->all(false);
}

public function key(int $index = 0): mixed
public function key(int $index = 0)
{
return (new Operation\Key())()($index)($this)->current();
}
Expand All @@ -493,7 +493,7 @@ public function keys(): CollectionInterface
return new self((new Operation\Keys())(), [$this]);
}

public function last(mixed $default = null): mixed
public function last(mixed $default = null)
{
return (new self((new Operation\Last())(), [$this]))->current(0, $default);
}
Expand Down Expand Up @@ -528,7 +528,7 @@ public function matching(Criteria $criteria): CollectionInterface
return new self((new Operation\Matching())()($criteria), [$this]);
}

public function max(mixed $default = null): mixed
public function max(mixed $default = null)
{
return (new self((new Operation\Max())(), [$this]))->current(0, $default);
}
Expand All @@ -538,7 +538,7 @@ public function merge(iterable ...$sources): CollectionInterface
return new self((new Operation\Merge())()(...$sources), [$this]);
}

public function min(mixed $default = null): mixed
public function min(mixed $default = null)
{
return (new self((new Operation\Min())(), [$this]))->current(0, $default);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Contract/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
* @template-extends Operation\Transposeable<TKey, T>
* @template-extends Operation\Truthyable<TKey, T>
* @template-extends Operation\Unlinesable<TKey, T>
* @template-extends Operation\Unpackable<mixed, array{0: TKey, 1: T}>
* @template-extends Operation\Unpackable<TKey, T>
* @template-extends Operation\Unpairable<TKey, T>
* @template-extends Operation\Untilable<TKey, T>
* @template-extends Operation\Unwindowable<TKey, T>
Expand Down
2 changes: 1 addition & 1 deletion src/Contract/Operation/Comparable.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ interface Comparable
*
* @return T|V
*/
public function compare(callable $comparator, mixed $default = null): mixed;
public function compare(callable $comparator, mixed $default = null);
}
2 changes: 1 addition & 1 deletion src/Contract/Operation/Currentable.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ interface Currentable
*
* @return T|V
*/
public function current(int $index = 0, mixed $default = null): mixed;
public function current(int $index = 0, mixed $default = null);
}
2 changes: 1 addition & 1 deletion src/Contract/Operation/Findable.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ interface Findable
*
* @return T|V
*/
public function find(mixed $default = null, callable ...$callbacks): mixed;
public function find(mixed $default = null, callable ...$callbacks);
}
2 changes: 1 addition & 1 deletion src/Contract/Operation/Firstable.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ interface Firstable
*
* @return T|V
*/
public function first(mixed $default = null): mixed;
public function first(mixed $default = null);
}
2 changes: 1 addition & 1 deletion src/Contract/Operation/Getable.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ interface Getable
*
* @return T|V
*/
public function get(mixed $key, mixed $default = null): mixed;
public function get(mixed $key, mixed $default = null);
}
2 changes: 1 addition & 1 deletion src/Contract/Operation/Headable.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ interface Headable
*
* @return T|V
*/
public function head(mixed $default = null): mixed;
public function head(mixed $default = null);
}
2 changes: 1 addition & 1 deletion src/Contract/Operation/Keyable.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ interface Keyable
*
* @return TKey|null
*/
public function key(int $index = 0): mixed;
public function key(int $index = 0);
}
2 changes: 1 addition & 1 deletion src/Contract/Operation/Lastable.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ interface Lastable
*
* @return T|V
*/
public function last(mixed $default = null): mixed;
public function last(mixed $default = null);
}
2 changes: 1 addition & 1 deletion src/Contract/Operation/Maxable.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ interface Maxable
*
* @return T|V
*/
public function max(mixed $default = null): mixed;
public function max(mixed $default = null);
}
2 changes: 1 addition & 1 deletion src/Contract/Operation/Minable.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ interface Minable
*
* @return T|V
*/
public function min(mixed $default = null): mixed;
public function min(mixed $default = null);
}
6 changes: 5 additions & 1 deletion src/Contract/Operation/Prependable.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ interface Prependable
*
* @see https://loophp-collection.readthedocs.io/en/stable/pages/api.html#prepend
*
* @return Collection<int|TKey, T>
* @template U
*
* @param U ...$items
*
* @return Collection<int|TKey, T|U>
*/
public function prepend(mixed ...$items): Collection;
}
2 changes: 1 addition & 1 deletion src/Contract/Operation/Unpackable.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface Unpackable
*
* @see https://loophp-collection.readthedocs.io/en/stable/pages/api.html#unpack
*
* @return Collection<mixed, mixed>
* @return Collection<TKey, T>
*/
public function unpack(): Collection;
}
Loading