Apply "SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2019-02-09 11:28:13 +01:00
parent 7e884cc0f4
commit cbe484a4d3
No known key found for this signature in database
GPG key ID: 221E9281655813A6
5 changed files with 8 additions and 6 deletions

View file

@ -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;
}
}

View file

@ -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" />

View file

@ -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();
}
?>

View file

@ -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();
}
?>

View file

@ -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));