Skip to content

Commit 66f2361

Browse files
Release v3.1.31 (#6944)
Co-authored-by: Deeka Wong <[email protected]>
1 parent 4eac760 commit 66f2361

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

Diff for: src/Fluent.php

+36-11
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,34 @@
1313
namespace Hyperf\Support;
1414

1515
use ArrayAccess;
16+
use Closure;
1617
use Hyperf\Contract\Arrayable;
1718
use Hyperf\Contract\Jsonable;
1819
use JsonSerializable;
1920

2021
/**
2122
* Most of the methods in this file come from illuminate/support,
2223
* thanks Laravel Team provide such a useful class.
24+
*
25+
* @template TKey of array-key
26+
* @template TValue
27+
*
28+
* @implements \Hyperf\Contract\Arrayable<TKey, TValue>
29+
* @implements \ArrayAccess<TKey, TValue>
2330
*/
2431
class Fluent implements ArrayAccess, Arrayable, Jsonable, JsonSerializable
2532
{
2633
/**
2734
* All the attributes set on the fluent instance.
2835
*
29-
* @var array
36+
* @var array<TKey, TValue>
3037
*/
3138
protected $attributes = [];
3239

3340
/**
3441
* Create a new fluent instance.
3542
*
36-
* @param array|object $attributes
43+
* @param iterable<TKey, TValue> $attributes
3744
*/
3845
public function __construct($attributes = [])
3946
{
@@ -45,7 +52,7 @@ public function __construct($attributes = [])
4552
/**
4653
* Handle dynamic calls to the fluent instance to set attributes.
4754
*
48-
* @param string $method
55+
* @param TKey $method
4956
* @param array $parameters
5057
* @return $this
5158
*/
@@ -59,7 +66,8 @@ public function __call($method, $parameters)
5966
/**
6067
* Dynamically retrieve the value of an attribute.
6168
*
62-
* @param string $key
69+
* @param TKey $key
70+
* @return null|TValue
6371
*/
6472
public function __get($key)
6573
{
@@ -69,8 +77,8 @@ public function __get($key)
6977
/**
7078
* Dynamically set the value of an attribute.
7179
*
72-
* @param string $key
73-
* @param mixed $value
80+
* @param TKey $key
81+
* @param TValue $value
7482
*/
7583
public function __set($key, $value)
7684
{
@@ -80,7 +88,7 @@ public function __set($key, $value)
8088
/**
8189
* Dynamically check if an attribute is set.
8290
*
83-
* @param string $key
91+
* @param TKey $key
8492
* @return bool
8593
*/
8694
public function __isset($key)
@@ -91,7 +99,7 @@ public function __isset($key)
9199
/**
92100
* Dynamically unset an attribute.
93101
*
94-
* @param string $key
102+
* @param TKey $key
95103
*/
96104
public function __unset($key)
97105
{
@@ -106,8 +114,11 @@ public function __toString(): string
106114
/**
107115
* Get an attribute from the fluent instance.
108116
*
109-
* @param string $key
110-
* @param null|mixed $default
117+
* @template TGetDefault
118+
*
119+
* @param TKey $key
120+
* @param (Closure(): TGetDefault)|TGetDefault $default
121+
* @return TGetDefault|TValue
111122
*/
112123
public function get($key, $default = null)
113124
{
@@ -121,7 +132,7 @@ public function get($key, $default = null)
121132
/**
122133
* Get the attributes from the fluent instance.
123134
*
124-
* @return array
135+
* @return array<TKey, TValue>
125136
*/
126137
public function getAttributes()
127138
{
@@ -130,6 +141,8 @@ public function getAttributes()
130141

131142
/**
132143
* Convert the fluent instance to an array.
144+
*
145+
* @return array<TKey, TValue>
133146
*/
134147
public function toArray(): array
135148
{
@@ -138,6 +151,8 @@ public function toArray(): array
138151

139152
/**
140153
* Convert the object into something JSON serializable.
154+
*
155+
* @return array<TKey, TValue>
141156
*/
142157
public function jsonSerialize(): mixed
143158
{
@@ -157,6 +172,8 @@ public function toJson($options = 0)
157172

158173
/**
159174
* Determine if the given offset exists.
175+
*
176+
* @param TKey $offset
160177
*/
161178
public function offsetExists(mixed $offset): bool
162179
{
@@ -165,6 +182,9 @@ public function offsetExists(mixed $offset): bool
165182

166183
/**
167184
* Get the value for a given offset.
185+
*
186+
* @param TKey $offset
187+
* @return null|TValue
168188
*/
169189
public function offsetGet(mixed $offset): mixed
170190
{
@@ -173,6 +193,9 @@ public function offsetGet(mixed $offset): mixed
173193

174194
/**
175195
* Set the value at the given offset.
196+
*
197+
* @param TKey $offset
198+
* @param TValue $value
176199
*/
177200
public function offsetSet(mixed $offset, mixed $value): void
178201
{
@@ -181,6 +204,8 @@ public function offsetSet(mixed $offset, mixed $value): void
181204

182205
/**
183206
* Unset the value at the given offset.
207+
*
208+
* @param TKey $offset
184209
*/
185210
public function offsetUnset(mixed $offset): void
186211
{

Diff for: src/Functions.php

+5
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ function getter(string $property): string
210210
* Create an object instance, if the DI container exist in ApplicationContext,
211211
* then the object will be created by DI container via `make()` method, if not,
212212
* the object will create by `new` keyword.
213+
*
214+
* @template TClass
215+
*
216+
* @param class-string<TClass>|string $name
217+
* @return ($name is class-string<TClass> ? TClass : mixed)
213218
*/
214219
function make(string $name, array $parameters = [])
215220
{

0 commit comments

Comments
 (0)