16
16
/**
17
17
* 按条件抛异常
18
18
*
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
23
26
*
24
- * @throws Throwable
27
+ * @throws TException
25
28
*/
26
29
function throw_if ($ condition , $ exception , ...$ parameters )
27
30
{
@@ -37,11 +40,15 @@ function throw_if($condition, $exception, ...$parameters)
37
40
/**
38
41
* 按条件抛异常
39
42
*
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
45
52
*/
46
53
function throw_unless ($ condition , $ exception , ...$ parameters )
47
54
{
@@ -57,9 +64,11 @@ function throw_unless($condition, $exception, ...$parameters)
57
64
/**
58
65
* 对一个值调用给定的闭包,然后返回该值
59
66
*
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
63
72
*/
64
73
function tap ($ value , $ callback = null )
65
74
{
@@ -77,8 +86,10 @@ function tap($value, $callback = null)
77
86
/**
78
87
* Return the default value of the given value.
79
88
*
80
- * @param mixed $value
81
- * @return mixed
89
+ * @template TValue
90
+ *
91
+ * @param TValue|\Closure(): TValue $value
92
+ * @return TValue
82
93
*/
83
94
function value ($ value )
84
95
{
0 commit comments