From 66f2361482c8ac88240a01f36b9faa3bf55bc24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Thu, 11 Jul 2024 10:05:39 +0800 Subject: [PATCH] Release v3.1.31 (#6944) Co-authored-by: Deeka Wong --- src/Fluent.php | 47 ++++++++++++++++++++++++++++++++++++----------- src/Functions.php | 5 +++++ 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/Fluent.php b/src/Fluent.php index 79e1e1c..00ad2df 100755 --- a/src/Fluent.php +++ b/src/Fluent.php @@ -13,6 +13,7 @@ namespace Hyperf\Support; use ArrayAccess; +use Closure; use Hyperf\Contract\Arrayable; use Hyperf\Contract\Jsonable; use JsonSerializable; @@ -20,20 +21,26 @@ /** * Most of the methods in this file come from illuminate/support, * thanks Laravel Team provide such a useful class. + * + * @template TKey of array-key + * @template TValue + * + * @implements \Hyperf\Contract\Arrayable + * @implements \ArrayAccess */ class Fluent implements ArrayAccess, Arrayable, Jsonable, JsonSerializable { /** * All the attributes set on the fluent instance. * - * @var array + * @var array */ protected $attributes = []; /** * Create a new fluent instance. * - * @param array|object $attributes + * @param iterable $attributes */ public function __construct($attributes = []) { @@ -45,7 +52,7 @@ public function __construct($attributes = []) /** * Handle dynamic calls to the fluent instance to set attributes. * - * @param string $method + * @param TKey $method * @param array $parameters * @return $this */ @@ -59,7 +66,8 @@ public function __call($method, $parameters) /** * Dynamically retrieve the value of an attribute. * - * @param string $key + * @param TKey $key + * @return null|TValue */ public function __get($key) { @@ -69,8 +77,8 @@ public function __get($key) /** * Dynamically set the value of an attribute. * - * @param string $key - * @param mixed $value + * @param TKey $key + * @param TValue $value */ public function __set($key, $value) { @@ -80,7 +88,7 @@ public function __set($key, $value) /** * Dynamically check if an attribute is set. * - * @param string $key + * @param TKey $key * @return bool */ public function __isset($key) @@ -91,7 +99,7 @@ public function __isset($key) /** * Dynamically unset an attribute. * - * @param string $key + * @param TKey $key */ public function __unset($key) { @@ -106,8 +114,11 @@ public function __toString(): string /** * Get an attribute from the fluent instance. * - * @param string $key - * @param null|mixed $default + * @template TGetDefault + * + * @param TKey $key + * @param (Closure(): TGetDefault)|TGetDefault $default + * @return TGetDefault|TValue */ public function get($key, $default = null) { @@ -121,7 +132,7 @@ public function get($key, $default = null) /** * Get the attributes from the fluent instance. * - * @return array + * @return array */ public function getAttributes() { @@ -130,6 +141,8 @@ public function getAttributes() /** * Convert the fluent instance to an array. + * + * @return array */ public function toArray(): array { @@ -138,6 +151,8 @@ public function toArray(): array /** * Convert the object into something JSON serializable. + * + * @return array */ public function jsonSerialize(): mixed { @@ -157,6 +172,8 @@ public function toJson($options = 0) /** * Determine if the given offset exists. + * + * @param TKey $offset */ public function offsetExists(mixed $offset): bool { @@ -165,6 +182,9 @@ public function offsetExists(mixed $offset): bool /** * Get the value for a given offset. + * + * @param TKey $offset + * @return null|TValue */ public function offsetGet(mixed $offset): mixed { @@ -173,6 +193,9 @@ public function offsetGet(mixed $offset): mixed /** * Set the value at the given offset. + * + * @param TKey $offset + * @param TValue $value */ public function offsetSet(mixed $offset, mixed $value): void { @@ -181,6 +204,8 @@ public function offsetSet(mixed $offset, mixed $value): void /** * Unset the value at the given offset. + * + * @param TKey $offset */ public function offsetUnset(mixed $offset): void { diff --git a/src/Functions.php b/src/Functions.php index 0310762..6071106 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -210,6 +210,11 @@ function getter(string $property): string * Create an object instance, if the DI container exist in ApplicationContext, * then the object will be created by DI container via `make()` method, if not, * the object will create by `new` keyword. + * + * @template TClass + * + * @param class-string|string $name + * @return ($name is class-string ? TClass : mixed) */ function make(string $name, array $parameters = []) {