mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 19:58:22 +08:00
style: 💄 cs fix
This commit is contained in:
parent
027496309d
commit
0993136cb5
@ -12,8 +12,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Hyperf\Validation\Middleware;
|
||||
|
||||
use Hyperf\Validation\Contracts\Validation\ValidatesWhenResolved;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Closure;
|
||||
use FastRoute\Dispatcher;
|
||||
use Hyperf\Contract\NormalizerInterface;
|
||||
@ -22,6 +20,8 @@ use Hyperf\HttpMessage\Stream\SwooleStream;
|
||||
use Hyperf\HttpServer\Router\DispatcherFactory;
|
||||
use Hyperf\Utils\Context;
|
||||
use Hyperf\Utils\Contracts\Arrayable;
|
||||
use Hyperf\Validation\Contracts\Validation\ValidatesWhenResolved;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
@ -41,8 +41,8 @@ class ValidationMiddleware implements MiddlewareInterface
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
$factory = $this->container->get(DispatcherFactory::class);
|
||||
$this->container = $container;
|
||||
$factory = $this->container->get(DispatcherFactory::class);
|
||||
$this->dispatcher = $factory->getDispatcher('http');
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ class ValidationMiddleware implements MiddlewareInterface
|
||||
// Do nothing
|
||||
} else {
|
||||
[$controller, $action] = $this->prepareHandler($routes[1]);
|
||||
if (!method_exists($controller, $action)) {
|
||||
if (! method_exists($controller, $action)) {
|
||||
// Route found, but the handler does not exist.
|
||||
return $this->response()->withStatus(500)->withBody(new SwooleStream('Method of class does not exist.'));
|
||||
}
|
||||
@ -124,7 +124,6 @@ class ValidationMiddleware implements MiddlewareInterface
|
||||
return Context::get(ResponseInterface::class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse the parameters of method definitions, and then bind the specified arguments or
|
||||
* get the value from DI container, combine to a argument array that should be injected
|
||||
|
@ -12,11 +12,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Hyperf\Validation\Request;
|
||||
|
||||
use Hyperf\Contract\ValidatorInterface;
|
||||
use Hyperf\HttpServer\Request;
|
||||
use Hyperf\Utils\Context;
|
||||
use Hyperf\Validation\Contracts\Validation\Factory as ValidationFactory;
|
||||
use Hyperf\Validation\Contracts\Validation\ValidatesWhenResolved;
|
||||
use Hyperf\Contract\ValidatorInterface;
|
||||
use Hyperf\Validation\ValidatesWhenResolvedTrait;
|
||||
use Hyperf\Validation\ValidationException;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
@ -14,17 +14,16 @@ namespace Hyperf\Validation;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Hyperf\Contract\TranslatorInterface;
|
||||
use Hyperf\Contract\ValidatorInterface;
|
||||
use Hyperf\Contract\ValidatorInterface as ValidatorContract;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\HttpMessage\Upload\UploadedFile;
|
||||
use Hyperf\Utils\Arr;
|
||||
use Hyperf\Utils\Contracts\MessageBag as MessageBagContract;
|
||||
use Hyperf\Utils\Fluent;
|
||||
use Hyperf\Utils\MessageBag;
|
||||
use Hyperf\Utils\Str;
|
||||
use Hyperf\Validation\Contracts\Validation\ImplicitRule;
|
||||
use Hyperf\Validation\Contracts\Validation\Rule as RuleContract;
|
||||
use Hyperf\Contract\ValidatorInterface as ValidatorContract;
|
||||
use Hyperf\Utils\MessageBag;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use RuntimeException;
|
||||
|
||||
@ -223,6 +222,8 @@ class Validator implements ValidatorContract
|
||||
/**
|
||||
* Handle dynamic calls to class methods.
|
||||
*
|
||||
* @param mixed $method
|
||||
* @param mixed $parameters
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
@ -324,7 +325,7 @@ class Validator implements ValidatorContract
|
||||
/**
|
||||
* Run the validator's rules against its data.
|
||||
*
|
||||
* @throws \Hyperf\Validation\ValidationException If validate fails.
|
||||
* @throws \Hyperf\Validation\ValidationException if validate fails
|
||||
*/
|
||||
public function validate(): array
|
||||
{
|
||||
@ -338,7 +339,7 @@ class Validator implements ValidatorContract
|
||||
/**
|
||||
* Get the attributes and values that were validated.
|
||||
*
|
||||
* @throws \Hyperf\Validation\ValidationException If invalid.
|
||||
* @throws \Hyperf\Validation\ValidationException if invalid
|
||||
*/
|
||||
public function validated(): array
|
||||
{
|
||||
@ -766,7 +767,7 @@ class Validator implements ValidatorContract
|
||||
/**
|
||||
* Validate a given attribute against a rule.
|
||||
*
|
||||
* @param string|object $rule
|
||||
* @param object|string $rule
|
||||
*/
|
||||
protected function validateAttribute(string $attribute, $rule)
|
||||
{
|
||||
@ -818,7 +819,7 @@ class Validator implements ValidatorContract
|
||||
/**
|
||||
* Determine if the given rule depends on other fields.
|
||||
*
|
||||
* @param string|object $rule
|
||||
* @param object|string $rule
|
||||
*/
|
||||
protected function dependsOnOtherFields($rule): bool
|
||||
{
|
||||
@ -873,6 +874,7 @@ class Validator implements ValidatorContract
|
||||
* Determine if the attribute is validatable.
|
||||
*
|
||||
* @param object|string $rule
|
||||
* @param mixed $value
|
||||
*/
|
||||
protected function isValidatable($rule, string $attribute, $value): bool
|
||||
{
|
||||
@ -886,6 +888,7 @@ class Validator implements ValidatorContract
|
||||
* Determine if the field is present, or the rule implies required.
|
||||
*
|
||||
* @param object|string $rule
|
||||
* @param mixed $value
|
||||
*/
|
||||
protected function presentOrRuleIsImplicit($rule, string $attribute, $value): bool
|
||||
{
|
||||
@ -926,7 +929,7 @@ class Validator implements ValidatorContract
|
||||
/**
|
||||
* Determine if the attribute fails the nullable check.
|
||||
*
|
||||
* @param string|object $rule
|
||||
* @param object|string $rule
|
||||
*/
|
||||
protected function isNotNullIfMarkedAsNullable($rule, string $attribute): bool
|
||||
{
|
||||
@ -942,7 +945,7 @@ class Validator implements ValidatorContract
|
||||
*
|
||||
* This is to avoid possible database type comparison errors.
|
||||
*
|
||||
* @param string|object $rule
|
||||
* @param object|string $rule
|
||||
*/
|
||||
protected function hasNotFailedPreviousRuleIfPresenceRule($rule, string $attribute): bool
|
||||
{
|
||||
@ -953,6 +956,7 @@ class Validator implements ValidatorContract
|
||||
* Validate an attribute using a custom rule object.
|
||||
*
|
||||
* @param \Hyperf\Validation\Contracts\Validation\Rule $rule
|
||||
* @param mixed $value
|
||||
*/
|
||||
protected function validateUsingCustomRule(string $attribute, $value, $rule)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user