mirror of
https://github.com/Respect/Validation.git
synced 2024-06-03 06:12:17 +02:00
Apply "SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
7e884cc0f4
commit
cbe484a4d3
|
@ -16,10 +16,10 @@ namespace Respect\Validation\Helpers;
|
|||
use Countable;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Exception;
|
||||
use function is_numeric;
|
||||
use function is_string;
|
||||
use function mb_strlen;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Helps to deal with comparable values.
|
||||
|
@ -52,7 +52,7 @@ trait CanCompareValues
|
|||
|
||||
try {
|
||||
return new DateTimeImmutable($value);
|
||||
} catch (Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator" />
|
||||
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator" />
|
||||
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch" />
|
||||
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly" />
|
||||
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue" />
|
||||
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse" />
|
||||
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration" />
|
||||
|
|
|
@ -14,7 +14,7 @@ Factory::setDefaultInstance(new Factory([], [], function (string $message): stri
|
|||
|
||||
try {
|
||||
v::not(v::alnum())->check('abc123');
|
||||
} catch (Exception $exception) {
|
||||
} catch (Throwable $exception) {
|
||||
echo $exception->getMessage();
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -14,7 +14,7 @@ $data = [
|
|||
|
||||
try {
|
||||
v::not(v::keyValue('password', 'in', 'invalid_passwords'))->check($data);
|
||||
} catch (Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Test\TestCase;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
|
@ -104,13 +105,13 @@ class KeyTest extends TestCase
|
|||
try {
|
||||
$rule->assert($input);
|
||||
self::fail('`assert()` must throws exception');
|
||||
} catch (\Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
}
|
||||
|
||||
try {
|
||||
$rule->check($input);
|
||||
self::fail('`check()` must throws exception');
|
||||
} catch (\Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
}
|
||||
|
||||
self::assertFalse($rule->validate($input));
|
||||
|
|
Loading…
Reference in a new issue