@@ -8,19 +8,19 @@ class Attribute
8
8
/** @var array */
9
9
protected $ rules = [];
10
10
11
- /** @var mixed */
11
+ /** @var string */
12
12
protected $ key ;
13
13
14
- /** @var mixed */
14
+ /** @var string|null */
15
15
protected $ alias ;
16
16
17
- /** @var mixed */
17
+ /** @var Rakit\Validation\Validation */
18
18
protected $ validation ;
19
19
20
20
/** @var bool */
21
21
protected $ required = false ;
22
22
23
- /** @var Attribute */
23
+ /** @var Rakit\Validation\Validation|null */
24
24
protected $ primaryAttribute = null ;
25
25
26
26
/** @var array */
@@ -32,14 +32,18 @@ class Attribute
32
32
/**
33
33
* Constructor
34
34
*
35
- * @param Validation $validation
36
- * @param mixed $key
37
- * @param mixed $alias
38
- * @param array $rules
35
+ * @param Rakit\ Validation\Validation $validation
36
+ * @param string $key
37
+ * @param string|null $alias
38
+ * @param array $rules
39
39
* @return void
40
40
*/
41
- public function __construct (Validation $ validation , $ key , $ alias = null , array $ rules = [])
42
- {
41
+ public function __construct (
42
+ Validation $ validation ,
43
+ string $ key ,
44
+ $ alias = null ,
45
+ array $ rules = []
46
+ ) {
43
47
$ this ->validation = $ validation ;
44
48
$ this ->alias = $ alias ;
45
49
$ this ->key = $ key ;
@@ -51,7 +55,7 @@ public function __construct(Validation $validation, $key, $alias = null, array $
51
55
/**
52
56
* Set the primary attribute
53
57
*
54
- * @param Attribute $primaryAttribute
58
+ * @param Rakit\Validation\ Attribute $primaryAttribute
55
59
* @return void
56
60
*/
57
61
public function setPrimaryAttribute (Attribute $ primaryAttribute )
@@ -73,7 +77,7 @@ public function setKeyIndexes(array $keyIndexes)
73
77
/**
74
78
* Get primary attributes
75
79
*
76
- * @return mixed
80
+ * @return Rakit\Validation\Attribute|null
77
81
*/
78
82
public function getPrimaryAttribute ()
79
83
{
@@ -97,7 +101,7 @@ public function setOtherAttributes(array $otherAttributes)
97
101
/**
98
102
* Add other attributes
99
103
*
100
- * @param Attribute $otherAttribute
104
+ * @param Rakit\Validation\ Attribute $otherAttribute
101
105
* @return void
102
106
*/
103
107
public function addOtherAttribute (Attribute $ otherAttribute )
@@ -118,7 +122,7 @@ public function getOtherAttributes(): array
118
122
/**
119
123
* Add rule
120
124
*
121
- * @param Rule $rule
125
+ * @param Rakit\Validation\ Rule $rule
122
126
* @return void
123
127
*/
124
128
public function addRule (Rule $ rule )
@@ -131,10 +135,10 @@ public function addRule(Rule $rule)
131
135
/**
132
136
* Get rule
133
137
*
134
- * @param mixed $ruleKey
138
+ * @param string $ruleKey
135
139
* @return void
136
140
*/
137
- public function getRule ($ ruleKey )
141
+ public function getRule (string $ ruleKey )
138
142
{
139
143
return $ this ->hasRule ($ ruleKey )? $ this ->rules [$ ruleKey ] : null ;
140
144
}
@@ -152,21 +156,21 @@ public function getRules(): array
152
156
/**
153
157
* Check the $ruleKey has in the rule
154
158
*
155
- * @param mixed $ruleKey
159
+ * @param string $ruleKey
156
160
* @return bool
157
161
*/
158
- public function hasRule ($ ruleKey ): bool
162
+ public function hasRule (string $ ruleKey ): bool
159
163
{
160
164
return isset ($ this ->rules [$ ruleKey ]);
161
165
}
162
166
163
167
/**
164
168
* Set required
165
169
*
166
- * @param mixed $required
170
+ * @param boolean $required
167
171
* @return void
168
172
*/
169
- public function setRequired ($ required )
173
+ public function setRequired (bool $ required )
170
174
{
171
175
$ this ->required = $ required ;
172
176
}
@@ -204,10 +208,10 @@ public function getKeyIndexes(): array
204
208
/**
205
209
* Get value
206
210
*
207
- * @param mixed $key
211
+ * @param string|null $key
208
212
* @return void
209
213
*/
210
- public function getValue ($ key = null )
214
+ public function getValue (string $ key = null )
211
215
{
212
216
if ($ key && $ this ->isArrayAttribute ()) {
213
217
$ key = $ this ->resolveSiblingKey ($ key );
@@ -225,28 +229,28 @@ public function getValue($key = null)
225
229
*
226
230
* @return boolean
227
231
*/
228
- public function isArrayAttribute ()
232
+ public function isArrayAttribute (): bool
229
233
{
230
234
return count ($ this ->getKeyIndexes ()) > 0 ;
231
235
}
232
236
233
237
/**
234
- * Check that is using dot notation
238
+ * Check this attribute is using dot notation
235
239
*
236
240
* @return boolean
237
241
*/
238
- public function isUsingDotNotation ()
242
+ public function isUsingDotNotation (): bool
239
243
{
240
244
return strpos ($ this ->getKey (), '. ' ) !== false ;
241
245
}
242
246
243
247
/**
244
248
* Resolve sibling key
245
249
*
246
- * @param mixed $key
247
- * @return mixed
250
+ * @param string $key
251
+ * @return string
248
252
*/
249
- public function resolveSiblingKey ($ key )
253
+ public function resolveSiblingKey (string $ key ): string
250
254
{
251
255
$ indexes = $ this ->getKeyIndexes ();
252
256
$ keys = explode ("* " , $ key );
@@ -285,18 +289,18 @@ public function getHumanizedKey()
285
289
/**
286
290
* Set alias
287
291
*
288
- * @param mixed $alias
292
+ * @param string $alias
289
293
* @return void
290
294
*/
291
- public function setAlias ($ alias )
295
+ public function setAlias (string $ alias )
292
296
{
293
297
$ this ->alias = $ alias ;
294
298
}
295
299
296
300
/**
297
301
* Get alias
298
302
*
299
- * @return mixed
303
+ * @return string|null
300
304
*/
301
305
public function getAlias ()
302
306
{
0 commit comments