Skip to content

Commit 612eea7

Browse files
ChinaMoliyunwuxin
authored andcommitted
完善辅助函数注释
1 parent eaf7d36 commit 612eea7

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

src/helper.php

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
/**
1717
* 按条件抛异常
1818
*
19-
* @param mixed $condition
20-
* @param Throwable|string $exception
21-
* @param array ...$parameters
22-
* @return mixed
19+
* @template TValue
20+
* @template TException of \Throwable
21+
*
22+
* @param TValue $condition
23+
* @param TException|class-string<TException>|string $exception
24+
* @param mixed ...$parameters
25+
* @return TValue
2326
*
24-
* @throws Throwable
27+
* @throws TException
2528
*/
2629
function throw_if($condition, $exception, ...$parameters)
2730
{
@@ -37,11 +40,15 @@ function throw_if($condition, $exception, ...$parameters)
3740
/**
3841
* 按条件抛异常
3942
*
40-
* @param mixed $condition
41-
* @param Throwable|string $exception
42-
* @param array ...$parameters
43-
* @return mixed
44-
* @throws Throwable
43+
* @template TValue
44+
* @template TException of \Throwable
45+
*
46+
* @param TValue $condition
47+
* @param TException|class-string<TException>|string $exception
48+
* @param mixed ...$parameters
49+
* @return TValue
50+
*
51+
* @throws TException
4552
*/
4653
function throw_unless($condition, $exception, ...$parameters)
4754
{
@@ -57,9 +64,11 @@ function throw_unless($condition, $exception, ...$parameters)
5764
/**
5865
* 对一个值调用给定的闭包,然后返回该值
5966
*
60-
* @param mixed $value
61-
* @param callable|null $callback
62-
* @return mixed
67+
* @template TValue
68+
*
69+
* @param TValue $value
70+
* @param (callable(TValue): mixed)|null $callback
71+
* @return TValue
6372
*/
6473
function tap($value, $callback = null)
6574
{
@@ -77,8 +86,10 @@ function tap($value, $callback = null)
7786
/**
7887
* Return the default value of the given value.
7988
*
80-
* @param mixed $value
81-
* @return mixed
89+
* @template TValue
90+
*
91+
* @param TValue|\Closure(): TValue $value
92+
* @return TValue
8293
*/
8394
function value($value)
8495
{

0 commit comments

Comments
 (0)