Skip to content

Commit f9618c4

Browse files
authored
Format code (#5172)
1 parent 39464f0 commit f9618c4

File tree

13 files changed

+50
-32
lines changed

13 files changed

+50
-32
lines changed

src/Concerns/ValidatesAttributes.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ public function isValidFileInstance($value): bool
11351135
/**
11361136
* Require a certain number of parameters to be present.
11371137
*
1138-
* @throws \InvalidArgumentException
1138+
* @throws InvalidArgumentException
11391139
*/
11401140
public function requireParameterCount(int $count, array $parameters, string $rule)
11411141
{
@@ -1217,7 +1217,7 @@ protected function checkDateTimeOrder(string $format, string $first, string $sec
12171217
/**
12181218
* Get a DateTime instance from a string.
12191219
*
1220-
* @return null|\DateTime
1220+
* @return null|DateTime
12211221
*/
12221222
protected function getDateTimeWithOptionalFormat(string $format, ?string $value)
12231223
{
@@ -1234,7 +1234,7 @@ protected function getDateTimeWithOptionalFormat(string $format, ?string $value)
12341234
/**
12351235
* Get a DateTime instance from a string with no format.
12361236
*
1237-
* @return null|\DateTime
1237+
* @return null|DateTime
12381238
*/
12391239
protected function getDateTime(string $value)
12401240
{
@@ -1503,7 +1503,7 @@ protected function getSize(string $attribute, $value): float|int|string
15031503
*
15041504
* @param mixed $first
15051505
* @param mixed $second
1506-
* @throws \InvalidArgumentException
1506+
* @throws InvalidArgumentException
15071507
*/
15081508
protected function compare($first, $second, string $operator): bool
15091509
{

src/Contract/ValidatorFactoryInterface.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
namespace Hyperf\Validation\Contract;
1313

14+
use Closure;
1415
use Hyperf\Contract\ValidatorInterface;
1516

1617
interface ValidatorFactoryInterface
@@ -23,15 +24,15 @@ public function make(array $data, array $rules, array $messages = [], array $cus
2324
/**
2425
* Register a custom validator extension.
2526
*/
26-
public function extend(string $rule, \Closure|string $extension, ?string $message = null);
27+
public function extend(string $rule, Closure|string $extension, ?string $message = null);
2728

2829
/**
2930
* Register a custom implicit validator extension.
3031
*/
31-
public function extendImplicit(string $rule, \Closure|string $extension, ?string $message = null);
32+
public function extendImplicit(string $rule, Closure|string $extension, ?string $message = null);
3233

3334
/**
3435
* Register a custom implicit validator message replacer.
3536
*/
36-
public function replacer(string $rule, \Closure|string $replacer);
37+
public function replacer(string $rule, Closure|string $replacer);
3738
}

src/Middleware/ValidationMiddleware.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Psr\Http\Message\ServerRequestInterface;
2929
use Psr\Http\Server\MiddlewareInterface;
3030
use Psr\Http\Server\RequestHandlerInterface;
31+
use RuntimeException;
3132

3233
class ValidationMiddleware implements MiddlewareInterface
3334
{
@@ -141,6 +142,6 @@ protected function prepareHandler(array|string $handler): array
141142
if (is_array($handler) && isset($handler[0], $handler[1])) {
142143
return $handler;
143144
}
144-
throw new \RuntimeException('Handler not exist.');
145+
throw new RuntimeException('Handler not exist.');
145146
}
146147
}

src/Rules/Dimensions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*/
1212
namespace Hyperf\Validation\Rules;
1313

14-
class Dimensions implements \Stringable
14+
use Stringable;
15+
16+
class Dimensions implements Stringable
1517
{
1618
/**
1719
* Create a new dimensions rule instance.

src/Rules/Exists.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*/
1212
namespace Hyperf\Validation\Rules;
1313

14-
class Exists implements \Stringable
14+
use Stringable;
15+
16+
class Exists implements Stringable
1517
{
1618
use DatabaseRule;
1719

src/Rules/In.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*/
1212
namespace Hyperf\Validation\Rules;
1313

14-
class In implements \Stringable
14+
use Stringable;
15+
16+
class In implements Stringable
1517
{
1618
/**
1719
* The name of the rule.

src/Rules/NotIn.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*/
1212
namespace Hyperf\Validation\Rules;
1313

14-
class NotIn implements \Stringable
14+
use Stringable;
15+
16+
class NotIn implements Stringable
1517
{
1618
/**
1719
* The name of the rule.

src/Rules/RequiredIf.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*/
1212
namespace Hyperf\Validation\Rules;
1313

14-
class RequiredIf implements \Stringable
14+
use Stringable;
15+
16+
class RequiredIf implements Stringable
1517
{
1618
/**
1719
* The condition that validates the attribute.

src/Rules/Unique.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
namespace Hyperf\Validation\Rules;
1313

1414
use Hyperf\Database\Model\Model;
15+
use Stringable;
1516

16-
class Unique implements \Stringable
17+
class Unique implements Stringable
1718
{
1819
use DatabaseRule;
1920

src/ValidationRuleParser.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Hyperf\Validation\Contract\Rule as RuleContract;
1818
use Hyperf\Validation\Rules\Exists;
1919
use Hyperf\Validation\Rules\Unique;
20+
use stdClass;
21+
use Stringable;
2022

2123
class ValidationRuleParser
2224
{
@@ -37,7 +39,7 @@ public function __construct(public array $data)
3739
/**
3840
* Parse the human-friendly rules into a full rules array for the validator.
3941
*
40-
* @return \stdClass
42+
* @return stdClass
4143
*/
4244
public function explode(array $rules)
4345
{
@@ -54,7 +56,7 @@ public function explode(array $rules)
5456
/**
5557
* Merge additional rules into a given attribute(s).
5658
*
57-
* @param array|string|\Stringable $rules
59+
* @param array|string|Stringable $rules
5860
*/
5961
public function mergeRules(array $results, array|string $attribute, mixed $rules = []): array
6062
{
@@ -155,7 +157,7 @@ protected function prepareRule($rule)
155157
/**
156158
* Define a set of rules that apply to each element in an array attribute.
157159
*
158-
* @param array|string|\Stringable $rules
160+
* @param array|string|Stringable $rules
159161
*/
160162
protected function explodeWildcardRules(array $results, string $attribute, mixed $rules): array
161163
{
@@ -179,7 +181,7 @@ protected function explodeWildcardRules(array $results, string $attribute, mixed
179181
/**
180182
* Merge additional rules into a given attribute.
181183
*
182-
* @param array|string|\Stringable $rules
184+
* @param array|string|Stringable $rules
183185
*/
184186
protected function mergeRulesForAttribute(array $results, string $attribute, mixed $rules): array
185187
{

0 commit comments

Comments
 (0)