Skip to content

Commit

Permalink
完善辅助函数注释
Browse files Browse the repository at this point in the history
  • Loading branch information
ChinaMoli authored and yunwuxin committed Aug 26, 2024
1 parent eaf7d36 commit 612eea7
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
/**
* 按条件抛异常
*
* @param mixed $condition
* @param Throwable|string $exception
* @param array ...$parameters
* @return mixed
* @template TValue
* @template TException of \Throwable
*
* @param TValue $condition
* @param TException|class-string<TException>|string $exception
* @param mixed ...$parameters
* @return TValue
*
* @throws Throwable
* @throws TException
*/
function throw_if($condition, $exception, ...$parameters)
{
Expand All @@ -37,11 +40,15 @@ function throw_if($condition, $exception, ...$parameters)
/**
* 按条件抛异常
*
* @param mixed $condition
* @param Throwable|string $exception
* @param array ...$parameters
* @return mixed
* @throws Throwable
* @template TValue
* @template TException of \Throwable
*
* @param TValue $condition
* @param TException|class-string<TException>|string $exception
* @param mixed ...$parameters
* @return TValue
*
* @throws TException
*/
function throw_unless($condition, $exception, ...$parameters)
{
Expand All @@ -57,9 +64,11 @@ function throw_unless($condition, $exception, ...$parameters)
/**
* 对一个值调用给定的闭包,然后返回该值
*
* @param mixed $value
* @param callable|null $callback
* @return mixed
* @template TValue
*
* @param TValue $value
* @param (callable(TValue): mixed)|null $callback
* @return TValue
*/
function tap($value, $callback = null)
{
Expand All @@ -77,8 +86,10 @@ function tap($value, $callback = null)
/**
* Return the default value of the given value.
*
* @param mixed $value
* @return mixed
* @template TValue
*
* @param TValue|\Closure(): TValue $value
* @return TValue
*/
function value($value)
{
Expand Down

0 comments on commit 612eea7

Please sign in to comment.