Skip to content

Commit

Permalink
Optimized phpdoc (#6927)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia authored Jul 4, 2024
1 parent 1667583 commit 1983983
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions src/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
if (! function_exists('value')) {
/**
* Return the default value of the given value.
* @template TValue
* @template TReturn
*
* @param (Closure():TReturn)|TValue $value
* @param mixed ...$args
* @return ($value is Closure ? TReturn : TValue)
*/
function value(mixed $value, ...$args)
{
Expand All @@ -36,8 +42,12 @@ function env($key, $default = null)
/**
* Retry an operation a given number of times.
*
* @template TReturn
*
* @param float|int $times
* @param callable(int):TReturn $callback
* @param int $sleep millisecond
* @return TReturn
* @throws Throwable
*/
function retry($times, callable $callback, int $sleep = 0)
Expand All @@ -49,7 +59,12 @@ function retry($times, callable $callback, int $sleep = 0)
/**
* Return the given value, optionally passed through the given callback.
*
* @param mixed $value
* @template TValue
* @template TReturn
*
* @param TValue $value
* @param null|(callable(TValue):TReturn) $callback
* @return ($callback is null ? TValue : TReturn)
*/
function with($value, ?callable $callback = null)
{
Expand All @@ -61,14 +76,18 @@ function with($value, ?callable $callback = null)
/**
* Create a collection from the given value.
*
* @param null|mixed $value
* @return Collection
* @template TKey of array-key
* @template TValue
*
* @param null|\Hyperf\Contract\Arrayable<TKey, TValue>|iterable<TKey, TValue> $value
* @return Collection<TKey, TValue>
*/
function collect($value = null)
{
return \Hyperf\Collection\collect($value);
}
}

if (! function_exists('data_fill')) {
/**
* Fill in data where it's missing.
Expand Down Expand Up @@ -134,12 +153,10 @@ function last($array)
if (! function_exists('tap')) {
/**
* Call the given Closure with the given value then return the value.
*
* @template TValue
*
* @param null|callable $callback
* @param TValue $value
* @return TValue
* @param null|callable $callback
* @return ($callback is null ? HigherOrderTapProxy<TValue> : TValue)
*/
function tap($value, $callback = null)
{
Expand Down Expand Up @@ -267,9 +284,12 @@ function swoole_hook_flags(): int
if (! function_exists('optional')) {
/**
* Provide access to optional objects.
* @template TValue
* @template TReturn
*
* @param mixed $value
* @return mixed
* @param TValue $value
* @param null|(callable(TValue):TReturn) $callback
* @return ($callback is null ? \Hyperf\Support\Optional<TValue> : ($value is null ? null : TReturn))
*/
function optional($value = null, ?callable $callback = null)
{
Expand All @@ -278,6 +298,12 @@ function optional($value = null, ?callable $callback = null)
}

if (! function_exists('wait')) {
/**
* @template TReturn
*
* @param Closure():TReturn $closure
* @return TReturn
*/
function wait(Closure $closure, ?float $timeout = null)
{
return \Hyperf\Coroutine\wait($closure, $timeout);
Expand Down

0 comments on commit 1983983

Please sign in to comment.