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

Chore: Fix types #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ jobs:
uses: "ramsey/composer-install@v1"

- name: "Run a static analysis with vimeo/psalm"
run: "vendor/bin/psalm
run: "vendor/bin/psalm"
2 changes: 1 addition & 1 deletion src/IterableObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
return (bool) $value;
};

return new self(new CallbackFilterIterator(new IteratorIterator($this->iterable), $filter));

Check failure on line 59 in src/IterableObject.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm (8.1)

PossiblyInvalidArgument

src/IterableObject.php:59:95: PossiblyInvalidArgument: Argument 2 of CallbackFilterIterator::__construct expects callable(TValue:BenTools\IterableFunctions\IterableObject as mixed, TKey:BenTools\IterableFunctions\IterableObject as mixed, Iterator<mixed, mixed>):bool|callable(TValue:BenTools\IterableFunctions\IterableObject as mixed, mixed, Iterator<mixed, mixed>):bool|callable(mixed, mixed, Iterator<mixed, mixed>):bool, but possibly different type callable(TValue:BenTools\IterableFunctions\IterableObject as mixed):bool|callable(TValue:BenTools\IterableFunctions\IterableObject as mixed, TKey:BenTools\IterableFunctions\IterableObject as mixed):bool|pure-Closure(mixed):bool provided (see https://psalm.dev/092)
}

$filtered = $filter === null
? array_filter($this->iterable)
: array_filter($this->iterable, $filter, ARRAY_FILTER_USE_BOTH);

Check failure on line 64 in src/IterableObject.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm (8.1)

PossiblyInvalidArgument

src/IterableObject.php:64:45: PossiblyInvalidArgument: Argument 2 of array_filter expects callable(TValue:BenTools\IterableFunctions\IterableObject as mixed, TKey:BenTools\IterableFunctions\IterableObject as mixed):mixed, but possibly different type callable(TValue:BenTools\IterableFunctions\IterableObject as mixed):bool|callable(TValue:BenTools\IterableFunctions\IterableObject as mixed, TKey:BenTools\IterableFunctions\IterableObject as mixed):bool provided (see https://psalm.dev/092)

return new self($filtered);
}
Expand Down Expand Up @@ -119,14 +119,14 @@
return new self(new WithoutKeysTraversable($this->iterable));
}

/** @return iterable<int, array<TKey, TValue>> */
/** @return iterable<int, iterable<TKey, TValue>> */
public function chunk(int $size): iterable
{
if ($this->iterable instanceof Traversable) {
return new ChunkIterator($this->iterable, $size, $this->preserveKeys);

Check failure on line 126 in src/IterableObject.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.1)

Method BenTools\IterableFunctions\IterableObject::chunk() should return iterable<int, iterable<TKey, TValue>> but returns BenTools\IterableFunctions\ChunkIterator<mixed, mixed>.
}

return array_chunk($this->iterable, $size, $this->preserveKeys);

Check failure on line 129 in src/IterableObject.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.1)

Method BenTools\IterableFunctions\IterableObject::chunk() should return iterable<int, iterable<TKey, TValue>> but returns array<array>.
}

/** @return Traversable<TKey, TValue> */
Expand Down
Loading