Skip to content

Commit c103827

Browse files
authored
Merge pull request #48 from ZhangChengLin/test
2 parents 1834c7c + 35ffe80 commit c103827

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/AbstractValidation.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ abstract class AbstractValidation implements ValidationInterface
2020
use ValidationTrait {
2121
//set as traitSet;
2222
// Methods to define an alias, can be used in the current class.
23-
get as traitGet;
23+
ValidationTrait::get as traitGet;
2424
}
2525

2626
/**

src/ValidationTrait.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ trait ValidationTrait
4747
{
4848
use FilteringTrait, ErrorMessageTrait, ScopedValidatorsTrait;
4949

50-
/** @var array The rules is by setRules() */
50+
/** @var array The rules are by setRules() */
5151
private $_rules = [];
5252

5353
/** @var array Through the validation of the data */
@@ -147,9 +147,9 @@ public function scenarios(): array
147147
*
148148
* @param Closure $cb
149149
*
150-
* @return $this|mixed
150+
* @return $this
151151
*/
152-
public function onBeforeValidate(Closure $cb)
152+
public function onBeforeValidate(Closure $cb): self
153153
{
154154
$this->_beforeHandler = $cb;
155155
return $this;
@@ -171,9 +171,9 @@ public function beforeValidate(): bool
171171
*
172172
* @param Closure $cb
173173
*
174-
* @return $this|mixed
174+
* @return $this
175175
*/
176-
public function onAfterValidate(Closure $cb)
176+
public function onAfterValidate(Closure $cb): self
177177
{
178178
$this->_afterHandler = $cb;
179179
return $this;
@@ -197,10 +197,10 @@ public function afterValidate(): void
197197
* @param array $onlyChecked You can set this field that needs verification
198198
* @param bool|null $stopOnError Stop verification if there is an error
199199
*
200-
* @return $this|mixed
200+
* @return $this
201201
* @throws InvalidArgumentException
202202
*/
203-
public function validate(array $onlyChecked = [], bool $stopOnError = null)
203+
public function validate(array $onlyChecked = [], bool $stopOnError = null): self
204204
{
205205
if (!property_exists($this, 'data')) {
206206
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
266266
$isEmpty = $rule['isEmpty'];
267267
}
268268

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
270270
$when = $rule['when'] ?? null;
271271
if ($when && ($when instanceof Closure) && $when($this->data, $this) !== true) {
272272
return;
@@ -406,7 +406,7 @@ protected function fieldValidate(string $field, $value, string $validator, array
406406
*/
407407
protected function valueValidate(string $field, $value, $validator, array $args, $defMsg): bool
408408
{
409-
// if field don't exists.
409+
// if field don't exist.
410410
if (null === $value) {
411411
$this->addError($field, $this->getMessage($validator, $field, $args, $defMsg));
412412
return false;
@@ -417,7 +417,7 @@ protected function valueValidate(string $field, $value, $validator, array $args,
417417

418418
$args = array_values($args);
419419
if (is_object($validator)) {
420-
// if $validator is a object has method '__invoke'
420+
// if $validator is an object has method '__invoke'
421421
if (method_exists($validator, '__invoke')) {
422422
$args[] = $this->data;
423423
$passed = $validator($value, ...$args);
@@ -706,9 +706,9 @@ public function getRules(): array
706706
/**
707707
* @param array $rules
708708
*
709-
* @return $this|static
709+
* @return $this
710710
*/
711-
public function setRules(array $rules)
711+
public function setRules(array $rules): self
712712
{
713713
$this->_rules = $rules;
714714
return $this;
@@ -733,9 +733,9 @@ public function getScene(): string
733733
/**
734734
* @param string $scene
735735
*
736-
* @return $this|mixed
736+
* @return $this
737737
*/
738-
public function atScene(string $scene)
738+
public function atScene(string $scene): self
739739
{
740740
$this->scene = trim($scene);
741741
return $this;
@@ -768,9 +768,9 @@ public function onScene(string $scene)
768768
/**
769769
* @param bool $_skipOnEmpty
770770
*
771-
* @return $this|mixed
771+
* @return $this
772772
*/
773-
public function setSkipOnEmpty(bool $_skipOnEmpty)
773+
public function setSkipOnEmpty(bool $_skipOnEmpty): self
774774
{
775775
$this->_skipOnEmpty = $_skipOnEmpty;
776776
return $this;
@@ -828,9 +828,9 @@ public function getRaw(string $key, $default = null)
828828
* @param string $key The data key
829829
* @param mixed $value The data value
830830
*
831-
* @return $this|mixed
831+
* @return $this
832832
*/
833-
public function setRaw(string $key, $value)
833+
public function setRaw(string $key, $value): self
834834
{
835835
$this->data[$key] = $value;
836836
return $this;

0 commit comments

Comments
 (0)