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 41931bc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
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<int|float> ? 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<int|float> ? 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 41931bc

Please sign in to comment.