Skip to content

Commit

Permalink
Fix return type of sortBy and sortByDescending methods
Browse files Browse the repository at this point in the history
  • Loading branch information
MortalFlesh committed Nov 25, 2023
1 parent 8bbbb9f commit d620ae9
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<!-- There is always Unreleased section on the top. Subsections (Add, Changed, Fix, Removed) should be Add as needed. -->
## Unreleased
- Fix return type of `sortBy` and `sortByDescending` methods

## 8.1.0 - 2023-05-19
- Add `Immutable\Generic\IList::choose` method
Expand Down
4 changes: 2 additions & 2 deletions src/Immutable/Generic/IList.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ public function sort(): IList;
public function sortDescending(): IList;

/**
* @phpstan-param callable(TValue, TValue): int<-1, 1> $callback
* @phpstan-param callable(TValue, TValue): (string|int|float) $callback
* @phpstan-return IList<TValue>
*/
public function sortBy(callable $callback): IList;

/**
* @phpstan-param callable(TValue, TIndex=): int<-1, 1> $callback
* @phpstan-param callable(TValue, TIndex=): (string|int|float) $callback
* @phpstan-return IList<TValue>
*/
public function sortByDescending(callable $callback): IList;
Expand Down
4 changes: 2 additions & 2 deletions src/Immutable/Generic/ISeq.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ public function sort(): ISeq;
public function sortDescending(): ISeq;

/**
* @phpstan-param callable(TValue, TValue): int<-1, 1> $callback
* @phpstan-param callable(TValue, TValue): (string|int|float) $callback
* @phpstan-return ISeq<TValue>
*
* @throws OutOfBoundsException
*/
public function sortBy(callable $callback): ISeq;

/**
* @phpstan-param callable(TValue): int<-1, 1> $callback
* @phpstan-param callable(TValue): (string|int|float) $callback
* @phpstan-return ISeq<TValue>
*
* @throws OutOfBoundsException
Expand Down
4 changes: 2 additions & 2 deletions src/Immutable/Generic/ListCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public function sortDescending(): IList
}

/**
* @phpstan-param callable(TValue, TValue): int<-1, 1> $callback
* @phpstan-param callable(TValue, TValue): (string|int|float) $callback
* @phpstan-return IList<TValue>
*/
public function sortBy(callable $callback): IList
Expand All @@ -381,7 +381,7 @@ public function sortBy(callable $callback): IList
}

/**
* @phpstan-param callable(TValue, TIndex=): int<-1, 1> $callback
* @phpstan-param callable(TValue, TIndex=): (string|int|float) $callback
* @phpstan-return IList<TValue>
*/
public function sortByDescending(callable $callback): IList
Expand Down
4 changes: 2 additions & 2 deletions src/Immutable/Generic/Seq.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public function sortDescending(): ISeq
}

/**
* @phpstan-param callable(TValue, TValue): int<-1, 1> $callback
* @phpstan-param callable(TValue, TValue): (string|int|float) $callback
* @phpstan-return ISeq<TValue>
*
* @throws OutOfBoundsException
Expand All @@ -695,7 +695,7 @@ public function sortBy(callable $callback): ISeq
}

/**
* @phpstan-param callable(TValue): int<-1, 1> $callback
* @phpstan-param callable(TValue): (string|int|float) $callback
* @phpstan-return ISeq<TValue>
*
* @throws OutOfBoundsException
Expand Down
4 changes: 2 additions & 2 deletions src/Mutable/Generic/IList.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public function sort(): void;

public function sortDescending(): void;

/** @phpstan-param callable(TValue, TValue): int<-1, 1> $callback */
/** @phpstan-param callable(TValue, TValue): (string|int|float) $callback */
public function sortBy(callable $callback): void;

/** @phpstan-param callable(TValue, TIndex=): int<-1, 1> $callback */
/** @phpstan-param callable(TValue, TIndex=): (string|int|float) $callback */
public function sortByDescending(callable $callback): void;

/** Keeps only unique values inside the list. */
Expand Down
4 changes: 2 additions & 2 deletions src/Mutable/Generic/ListCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function sortDescending(): void
rsort($this->listArray);
}

/** @phpstan-param callable(TValue, TValue): int<-1, 1> $callback */
/** @phpstan-param callable(TValue, TValue): (string|int|float) $callback */
public function sortBy(callable $callback): void
{
$callback = Callback::curry($callback);
Expand All @@ -328,7 +328,7 @@ public function sortBy(callable $callback): void
);
}

/** @phpstan-param callable(TValue, TIndex=): int<-1, 1> $callback */
/** @phpstan-param callable(TValue, TIndex=): (string|int|float) $callback */
public function sortByDescending(callable $callback): void
{
$callback = Callback::curry($callback);
Expand Down

0 comments on commit d620ae9

Please sign in to comment.