Skip to content

Commit

Permalink
feat: narrow return type for min(), max(), median() and mean()
Browse files Browse the repository at this point in the history
Consider whether the input is empty or not
  • Loading branch information
simPod committed Apr 6, 2024
1 parent c34e6c2 commit 0773dfd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/component/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
- [max](./../../src/Psl/Math/max.php#L19)
- [max_by](./../../src/Psl/Math/max_by.php#L24)
- [maxva](./../../src/Psl/Math/maxva.php#L20)
- [mean](./../../src/Psl/Math/mean.php#L18)
- [median](./../../src/Psl/Math/median.php#L19)
- [mean](./../../src/Psl/Math/mean.php#L20)
- [median](./../../src/Psl/Math/median.php#L21)
- [min](./../../src/Psl/Math/min.php#L19)
- [min_by](./../../src/Psl/Math/min_by.php#L24)
- [minva](./../../src/Psl/Math/minva.php#L20)
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Math/max.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @param list<T> $numbers
*
* @return T|null
* @return ($numbers is non-empty-list<T> ? T : null)
*
* @pure
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Psl/Math/mean.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*
* @param list<int|float> $numbers
*
* @return ($numbers is non-empty-list ? float : null)
*
* @pure
*/
function mean(array $numbers): ?float
Expand Down
2 changes: 2 additions & 0 deletions src/Psl/Math/median.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*
* @param list<int|float> $numbers
*
* @return ($numbers is non-empty-list ? float : null)
*
* @pure
*/
function median(array $numbers): ?float
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Math/min.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @param list<T> $numbers
*
* @return T|null
* @return ($numbers is non-empty-list<T> ? T : null)
*
* @pure
*/
Expand Down

0 comments on commit 0773dfd

Please sign in to comment.