Skip to content

Commit aeaa639

Browse files
committed
Optimized
1 parent c5a5df0 commit aeaa639

20 files changed

+317
-341
lines changed

src/ClosureValidationRule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
namespace Hyperf\Validation;
1414

15-
use Hyperf\Validation\Contracts\Validation\Rule as RuleContract;
15+
use Hyperf\Validation\Contract\Rule;
16+
use Hyperf\Validation\Contract\Rule as RuleContract;
1617

1718
class ClosureValidationRule implements RuleContract
1819
{

src/ConfigProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
namespace Hyperf\Validation;
1414

15-
use Hyperf\Validation\Contracts\Validation\Factory as FactoryInterface;
15+
use Hyperf\Validation\Contract\ValidatorFactoryInterface as FactoryInterface;
16+
use Hyperf\Validation\Contract\PresenceVerifierInterface;
1617

1718
class ConfigProvider
1819
{
@@ -21,7 +22,7 @@ public function __invoke(): array
2122
return [
2223
'dependencies' => [
2324
PresenceVerifierInterface::class => DatabasePresenceVerifierFactory::class,
24-
FactoryInterface::class => ValidatorFactory::class,
25+
FactoryInterface::class => ValidatorFactoryFactory::class,
2526
],
2627
'scan' => [
2728
'paths' => [
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
1111
*/
1212

13-
namespace Hyperf\Validation\Contracts\Validation;
13+
namespace Hyperf\Validation\Contract;
14+
15+
use Hyperf\Validation\Contract\Rule;
1416

1517
interface ImplicitRule extends Rule
1618
{

src/PresenceVerifierInterface.php renamed to src/Contract/PresenceVerifierInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
1111
*/
1212

13-
namespace Hyperf\Validation;
13+
namespace Hyperf\Validation\Contract;
1414

1515
interface PresenceVerifierInterface
1616
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
1111
*/
1212

13-
namespace Hyperf\Validation\Contracts\Validation;
13+
namespace Hyperf\Validation\Contract;
1414

1515
interface Rule
1616
{

src/Contracts/Validation/ValidatesWhenResolved.php renamed to src/Contract/ValidatesWhenResolved.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
1111
*/
1212

13-
namespace Hyperf\Validation\Contracts\Validation;
13+
namespace Hyperf\Validation\Contract;
1414

1515
interface ValidatesWhenResolved
1616
{

src/Contracts/Validation/Factory.php renamed to src/Contract/ValidatorFactoryInterface.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,30 @@
1010
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
1111
*/
1212

13-
namespace Hyperf\Validation\Contracts\Validation;
13+
namespace Hyperf\Validation\Contract;
1414

15-
interface Factory
15+
use Hyperf\Contract\ValidatorInterface;
16+
17+
interface ValidatorFactoryInterface
1618
{
1719
/**
1820
* Create a new Validator instance.
19-
*
20-
* @return \Hyperf\Contract\ValidatorInterface
2121
*/
22-
public function make(array $data, array $rules, array $messages = [], array $customAttributes = []);
22+
public function make(array $data, array $rules, array $messages = [], array $customAttributes = []): ValidatorInterface;
2323

2424
/**
2525
* Register a custom validator extension.
2626
*
2727
* @param \Closure|string $extension
28-
* @param null|string $message
2928
*/
30-
public function extend(string $rule, $extension, $message = null);
29+
public function extend(string $rule, $extension, ?string $message = null);
3130

3231
/**
3332
* Register a custom implicit validator extension.
3433
*
3534
* @param \Closure|string $extension
36-
* @param null|string $message
3735
*/
38-
public function extendImplicit(string $rule, $extension, $message = null);
36+
public function extendImplicit(string $rule, $extension, ?string $message = null);
3937

4038
/**
4139
* Register a custom implicit validator message replacer.

src/DatabasePresenceVerifier.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Closure;
1616
use Hyperf\Database\ConnectionResolverInterface;
1717
use Hyperf\Utils\Str;
18+
use Hyperf\Validation\Contract\PresenceVerifierInterface;
1819

1920
class DatabasePresenceVerifier implements PresenceVerifierInterface
2021
{

src/Factory.php

Lines changed: 0 additions & 263 deletions
This file was deleted.

src/Middleware/ValidationMiddleware.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
use Hyperf\HttpServer\Router\Dispatched;
1818
use Hyperf\Server\Exception\ServerException;
1919
use Hyperf\Utils\Context;
20-
use Hyperf\Validation\Contracts\Validation\ValidatesWhenResolved;
20+
use Hyperf\Validation\Contract\ValidatesWhenResolved;
2121
use Hyperf\Validation\UnauthorizedException;
22+
use Hyperf\Validation\ValidationException;
2223
use Psr\Container\ContainerInterface;
2324
use Psr\Http\Message\ResponseInterface;
2425
use Psr\Http\Message\ServerRequestInterface;
@@ -67,7 +68,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
6768
$classname = $parameter->getType()->getName();
6869
$implements = $this->getClassImplements($classname);
6970
if (in_array(ValidatesWhenResolved::class, $implements, true)) {
70-
/** @var ValidatesWhenResolved $parameterInstance */
71+
/** @var \Hyperf\Validation\Contract\ValidatesWhenResolved $parameterInstance */
7172
$parameterInstance = $this->container->get($classname);
7273
$parameterInstance->validateResolved();
7374
}

0 commit comments

Comments
 (0)