@@ -47,7 +47,7 @@ trait ValidationTrait
47
47
{
48
48
use FilteringTrait, ErrorMessageTrait, ScopedValidatorsTrait;
49
49
50
- /** @var array The rules is by setRules() */
50
+ /** @var array The rules are by setRules() */
51
51
private $ _rules = [];
52
52
53
53
/** @var array Through the validation of the data */
@@ -147,9 +147,9 @@ public function scenarios(): array
147
147
*
148
148
* @param Closure $cb
149
149
*
150
- * @return $this|mixed
150
+ * @return $this
151
151
*/
152
- public function onBeforeValidate (Closure $ cb )
152
+ public function onBeforeValidate (Closure $ cb ): self
153
153
{
154
154
$ this ->_beforeHandler = $ cb ;
155
155
return $ this ;
@@ -171,9 +171,9 @@ public function beforeValidate(): bool
171
171
*
172
172
* @param Closure $cb
173
173
*
174
- * @return $this|mixed
174
+ * @return $this
175
175
*/
176
- public function onAfterValidate (Closure $ cb )
176
+ public function onAfterValidate (Closure $ cb ): self
177
177
{
178
178
$ this ->_afterHandler = $ cb ;
179
179
return $ this ;
@@ -197,10 +197,10 @@ public function afterValidate(): void
197
197
* @param array $onlyChecked You can set this field that needs verification
198
198
* @param bool|null $stopOnError Stop verification if there is an error
199
199
*
200
- * @return $this|mixed
200
+ * @return $this
201
201
* @throws InvalidArgumentException
202
202
*/
203
- public function validate (array $ onlyChecked = [], bool $ stopOnError = null )
203
+ public function validate (array $ onlyChecked = [], bool $ stopOnError = null ): self
204
204
{
205
205
if (!property_exists ($ this , 'data ' )) {
206
206
throw new InvalidArgumentException ('Must be defined property "data"(array) in the sub-class used. ' );
@@ -266,7 +266,7 @@ protected function applyRule($fields, array $rule, array $onlyChecked, bool $sto
266
266
$ isEmpty = $ rule ['isEmpty ' ];
267
267
}
268
268
269
- // Preconditions for verification -- If do not meet the conditions, skip this rule
269
+ // Preconditions for verification -- If you do not meet the conditions, skip this rule
270
270
$ when = $ rule ['when ' ] ?? null ;
271
271
if ($ when && ($ when instanceof Closure) && $ when ($ this ->data , $ this ) !== true ) {
272
272
return ;
@@ -406,7 +406,7 @@ protected function fieldValidate(string $field, $value, string $validator, array
406
406
*/
407
407
protected function valueValidate (string $ field , $ value , $ validator , array $ args , $ defMsg ): bool
408
408
{
409
- // if field don't exists .
409
+ // if field don't exist .
410
410
if (null === $ value ) {
411
411
$ this ->addError ($ field , $ this ->getMessage ($ validator , $ field , $ args , $ defMsg ));
412
412
return false ;
@@ -417,7 +417,7 @@ protected function valueValidate(string $field, $value, $validator, array $args,
417
417
418
418
$ args = array_values ($ args );
419
419
if (is_object ($ validator )) {
420
- // if $validator is a object has method '__invoke'
420
+ // if $validator is an object has method '__invoke'
421
421
if (method_exists ($ validator , '__invoke ' )) {
422
422
$ args [] = $ this ->data ;
423
423
$ passed = $ validator ($ value , ...$ args );
@@ -706,9 +706,9 @@ public function getRules(): array
706
706
/**
707
707
* @param array $rules
708
708
*
709
- * @return $this|static
709
+ * @return $this
710
710
*/
711
- public function setRules (array $ rules )
711
+ public function setRules (array $ rules ): self
712
712
{
713
713
$ this ->_rules = $ rules ;
714
714
return $ this ;
@@ -733,9 +733,9 @@ public function getScene(): string
733
733
/**
734
734
* @param string $scene
735
735
*
736
- * @return $this|mixed
736
+ * @return $this
737
737
*/
738
- public function atScene (string $ scene )
738
+ public function atScene (string $ scene ): self
739
739
{
740
740
$ this ->scene = trim ($ scene );
741
741
return $ this ;
@@ -768,9 +768,9 @@ public function onScene(string $scene)
768
768
/**
769
769
* @param bool $_skipOnEmpty
770
770
*
771
- * @return $this|mixed
771
+ * @return $this
772
772
*/
773
- public function setSkipOnEmpty (bool $ _skipOnEmpty )
773
+ public function setSkipOnEmpty (bool $ _skipOnEmpty ): self
774
774
{
775
775
$ this ->_skipOnEmpty = $ _skipOnEmpty ;
776
776
return $ this ;
@@ -828,9 +828,9 @@ public function getRaw(string $key, $default = null)
828
828
* @param string $key The data key
829
829
* @param mixed $value The data value
830
830
*
831
- * @return $this|mixed
831
+ * @return $this
832
832
*/
833
- public function setRaw (string $ key , $ value )
833
+ public function setRaw (string $ key , $ value ): self
834
834
{
835
835
$ this ->data [$ key ] = $ value ;
836
836
return $ this ;
0 commit comments