Skip to content

Commit

Permalink
remove all phpstan errors (#107)
Browse files Browse the repository at this point in the history
* remove all phpstan errors

* change tactic
  • Loading branch information
akondas authored May 30, 2024
1 parent 7a6c345 commit c7772f7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 32 deletions.
10 changes: 0 additions & 10 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,3 @@ parameters:
- src
- tests
- generators
ignoreErrors:
-
message: "#Template type T of method#"
count: 6
path: src/Collection/Stream/Collectors.php

-
message: "#Method Munus\\\\Value::toStream\\(\\) should return Munus\\\\Collection\\\\Stream\\<T\\> but returns Munus\\\\Collection\\\\Stream\\\\Cons\\<Munus\\\\Collection\\\\Stream\\|T\\>.#"
count: 1
path: src/Value.php
2 changes: 1 addition & 1 deletion src/Collection/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static function iterate($seed, callable $iterator): self
* @param U $head
* @param callable():U $supplier
*
* @return Cons<U>
* @return self<U>
*/
public static function cons($head, callable $supplier): self
{
Expand Down
28 changes: 8 additions & 20 deletions src/Collection/Stream/Collectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,21 @@
final class Collectors
{
/**
* @template T
*
* @return Collector<T,GenericList>
* @return Collector<mixed,GenericList>
*/
public static function toList(): Collector
{
return GenericCollector::of(GenericList::empty(), /** @param T $value */ function (GenericList $list, $value): GenericList {
return GenericCollector::of(GenericList::empty(), function (GenericList $list, $value): GenericList {
return $list->append($value);
});
}

/**
* @template T
*
* @return Collector<T,Set>
* @return Collector<mixed,Set>
*/
public static function toSet(): Collector
{
return GenericCollector::of(Set::empty(), /** @param T $value */ function (Set $set, $value): Set {
return GenericCollector::of(Set::empty(), function (Set $set, $value): Set {
return $set->add($value);
});
}
Expand All @@ -56,9 +52,7 @@ public static function toMap(callable $keyMapper, ?callable $valueMapper = null)
}

/**
* @template T
*
* @return Collector<T,int|float>
* @return Collector<mixed,int|float>
*/
public static function summing(): Collector
{
Expand All @@ -80,9 +74,7 @@ function ($sum, $value) {
}

/**
* @template T
*
* @return Collector<T,string>
* @return Collector<mixed,string>
*/
public static function joining(string $glue = ''): Collector
{
Expand All @@ -94,19 +86,15 @@ public static function joining(string $glue = ''): Collector
}

/**
* @template T
*
* @return Collector<T,int>
* @return Collector<mixed,int>
*/
public static function counting(): Collector
{
return GenericCollector::of(0, /** @param T $value */ function (int $count, $value): int {return ++$count; });
}

/**
* @template T
*
* @return Collector<T,int|float>
* @return Collector<mixed,int|float>
*/
public static function averaging(): Collector
{
Expand Down
5 changes: 4 additions & 1 deletion src/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,12 @@ public function toStream(): Stream

$iterator = $this->iterator();

return Stream::cons($iterator->next(), function () use ($iterator) {
/** @var Stream<T> $stream */
$stream = Stream::cons($iterator->next(), function () use ($iterator) {
return $iterator->hasNext() ? $iterator->next() : Stream::empty();
});

return $stream;
}

/**
Expand Down

0 comments on commit c7772f7

Please sign in to comment.