Skip to content

Commit 214a0cf

Browse files
committed
Format
1 parent f1e38a4 commit 214a0cf

File tree

9 files changed

+14
-30
lines changed

9 files changed

+14
-30
lines changed

src/Concerns/ValidatesAttributes.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ trait ValidatesAttributes
3737
* Validate that an attribute was "accepted".
3838
*
3939
* This validation rule implies the attribute is "required".
40-
*
4140
* @param mixed $value
4241
*/
4342
public function validateAccepted(string $attribute, $value): bool

src/ConfigProvider.php

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

1313
namespace Hyperf\Validation;
1414

15-
use Hyperf\Validation\Contract\ValidatorFactoryInterface as FactoryInterface;
1615
use Hyperf\Validation\Contract\PresenceVerifierInterface;
16+
use Hyperf\Validation\Contract\ValidatorFactoryInterface as FactoryInterface;
1717

1818
class ConfigProvider
1919
{

src/Contract/ImplicitRule.php

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

1313
namespace Hyperf\Validation\Contract;
1414

15-
use Hyperf\Validation\Contract\Rule;
16-
1715
interface ImplicitRule extends Rule
1816
{
1917
}

src/Middleware/ValidationMiddleware.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,14 @@
1919
use Hyperf\Utils\Context;
2020
use Hyperf\Validation\Contract\ValidatesWhenResolved;
2121
use Hyperf\Validation\UnauthorizedException;
22-
use Hyperf\Validation\ValidationException;
2322
use Psr\Container\ContainerInterface;
2423
use Psr\Http\Message\ResponseInterface;
2524
use Psr\Http\Message\ServerRequestInterface;
2625
use Psr\Http\Server\MiddlewareInterface;
2726
use Psr\Http\Server\RequestHandlerInterface;
28-
use Hyperf\HttpServer\Contract\ResponseInterface as HyperfResponseInterface;
2927

3028
class ValidationMiddleware implements MiddlewareInterface
3129
{
32-
3330
/**
3431
* @var \Psr\Container\ContainerInterface
3532
*/

src/Request/FormRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use Hyperf\Contract\ValidatorInterface;
1616
use Hyperf\HttpServer\Request;
1717
use Hyperf\Utils\Context;
18-
use Hyperf\Validation\Contract\ValidatorFactoryInterface as ValidationFactory;
1918
use Hyperf\Validation\Contract\ValidatesWhenResolved;
19+
use Hyperf\Validation\Contract\ValidatorFactoryInterface as ValidationFactory;
2020
use Hyperf\Validation\UnauthorizedException;
2121
use Hyperf\Validation\ValidatesWhenResolvedTrait;
2222
use Hyperf\Validation\ValidationException;

src/Validator.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function __construct(
224224
*
225225
* @param mixed $method
226226
* @param mixed $parameters
227-
* @throws \BadMethodCallException
227+
* @throws \BadMethodCallException when method does not exist
228228
*/
229229
public function __call($method, $parameters)
230230
{
@@ -708,9 +708,8 @@ public function setFallbackMessages(array $messages)
708708
* Get the Presence Verifier implementation.
709709
*
710710
*@throws \RuntimeException
711-
* @return \Hyperf\Validation\Contract\PresenceVerifierInterface
712711
*/
713-
public function getPresenceVerifier()
712+
public function getPresenceVerifier(): PresenceVerifierInterface
714713
{
715714
if (! isset($this->presenceVerifier)) {
716715
throw new RuntimeException('Presence verifier has not been set.');
@@ -723,9 +722,8 @@ public function getPresenceVerifier()
723722
* Get the Presence Verifier implementation.
724723
*
725724
* @throws \RuntimeException
726-
* @return \Hyperf\Validation\Contract\PresenceVerifierInterface
727725
*/
728-
public function getPresenceVerifierFor(?string $connection)
726+
public function getPresenceVerifierFor(?string $connection): PresenceVerifierInterface
729727
{
730728
return tap($this->getPresenceVerifier(), function ($verifier) use ($connection) {
731729
$verifier->setConnection($connection);
@@ -954,11 +952,9 @@ protected function hasNotFailedPreviousRuleIfPresenceRule($rule, string $attribu
954952

955953
/**
956954
* Validate an attribute using a custom rule object.
957-
*
958-
* @param \Hyperf\Validation\Contract\Rule $rule
959955
* @param mixed $value
960956
*/
961-
protected function validateUsingCustomRule(string $attribute, $value, $rule)
957+
protected function validateUsingCustomRule(string $attribute, $value, RuleContract $rule)
962958
{
963959
if (! $rule->passes($attribute, $value)) {
964960
$this->failedRules[$attribute][get_class($rule)] = [];
@@ -1012,12 +1008,11 @@ protected function attributesThatHaveMessages(): array
10121008
* Get a rule and its parameters for a given attribute.
10131009
*
10141010
* @param array|string $rules
1015-
* @return null|array
10161011
*/
1017-
protected function getRule(string $attribute, $rules)
1012+
protected function getRule(string $attribute, $rules): ?array
10181013
{
10191014
if (! array_key_exists($attribute, $this->rules)) {
1020-
return;
1015+
return null;
10211016
}
10221017

10231018
$rules = (array) $rules;
@@ -1029,12 +1024,11 @@ protected function getRule(string $attribute, $rules)
10291024
return [$rule, $parameters];
10301025
}
10311026
}
1027+
return null;
10321028
}
10331029

10341030
/**
10351031
* Get the value of a given attribute.
1036-
*
1037-
* @return mixed
10381032
*/
10391033
protected function getValue(string $attribute)
10401034
{
@@ -1043,10 +1037,8 @@ protected function getValue(string $attribute)
10431037

10441038
/**
10451039
* Call a custom validator extension.
1046-
*
1047-
* @return null|bool
10481040
*/
1049-
protected function callExtension(string $rule, array $parameters)
1041+
protected function callExtension(string $rule, array $parameters): ?bool
10501042
{
10511043
$callback = $this->extensions[$rule];
10521044

@@ -1060,10 +1052,8 @@ protected function callExtension(string $rule, array $parameters)
10601052

10611053
/**
10621054
* Call a class based validator extension.
1063-
*
1064-
* @return bool
10651055
*/
1066-
protected function callClassBasedExtension(string $callback, array $parameters)
1056+
protected function callClassBasedExtension(string $callback, array $parameters): bool
10671057
{
10681058
[$class, $method] = Str::parseCallback($callback, 'validate');
10691059

src/ValidatorFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
use Hyperf\Contract\TranslatorInterface;
1717
use Hyperf\Contract\ValidatorInterface;
1818
use Hyperf\Utils\Str;
19-
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
2019
use Hyperf\Validation\Contract\PresenceVerifierInterface;
20+
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
2121
use Psr\Container\ContainerInterface;
2222

2323
class ValidatorFactory implements ValidatorFactoryInterface

tests/Cases/ValidationFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
namespace HyperfTest\Validation\Cases;
1414

1515
use Hyperf\Contract\TranslatorInterface;
16-
use Hyperf\Validation\ValidatorFactory;
1716
use Hyperf\Validation\Contract\PresenceVerifierInterface;
1817
use Hyperf\Validation\Validator;
18+
use Hyperf\Validation\ValidatorFactory;
1919
use Mockery as m;
2020
use PHPUnit\Framework\TestCase;
2121

tests/Cases/ValidationValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
use Hyperf\Utils\ApplicationContext;
2525
use Hyperf\Utils\Arr;
2626
use Hyperf\Validation\Contract\ImplicitRule;
27-
use Hyperf\Validation\Contract\Rule;
2827
use Hyperf\Validation\Contract\PresenceVerifierInterface;
28+
use Hyperf\Validation\Contract\Rule;
2929
use Hyperf\Validation\Rules\Exists;
3030
use Hyperf\Validation\Rules\Unique;
3131
use Hyperf\Validation\ValidationData;

0 commit comments

Comments
 (0)