From 84f1d3296ef4077c1a023589ad735e8e44c304be Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 29 Jan 2024 22:13:44 +0100 Subject: [PATCH] Remove "@throws" annotations I don't find much use for those, and it's hard to be consistent with all places that could throw an exception. Signed-off-by: Henrique Moody --- library/Factory.php | 7 ------- library/Rules/Between.php | 3 --- library/Rules/Charset.php | 3 --- library/Rules/CountryCode.php | 3 --- library/Rules/CreditCard.php | 3 --- library/Rules/Date.php | 3 --- library/Rules/FilterVar.php | 3 --- library/Rules/Ip.php | 3 --- library/Rules/KeySet.php | 3 --- library/Rules/LanguageCode.php | 3 --- library/Rules/Length.php | 3 --- library/Rules/Time.php | 3 --- library/Rules/Type.php | 3 --- library/Rules/Url.php | 4 ---- library/Rules/Uuid.php | 3 --- library/Rules/VideoUrl.php | 3 --- library/Validator.php | 5 ----- 17 files changed, 58 deletions(-) diff --git a/library/Factory.php b/library/Factory.php index 855c2c8e0..9fa29d87d 100644 --- a/library/Factory.php +++ b/library/Factory.php @@ -86,8 +86,6 @@ public function withParameterStringifier(ParameterStringifier $parameterStringif /** * @param mixed[] $arguments - * - * @throws ComponentException */ public function rule(string $ruleName, array $arguments = []): Validatable { @@ -111,8 +109,6 @@ public function rule(string $ruleName, array $arguments = []): Validatable /** * @param mixed[] $extraParams - * - * @throws ComponentException */ public function exception(Validatable $validatable, mixed $input, array $extraParams = []): ValidationException { @@ -149,9 +145,6 @@ public static function setDefaultInstance(self $defaultInstance): void * @param class-string $name * @param class-string $parentName * - * @throws InvalidClassException - * @throws ReflectionException - * * @return ReflectionClass */ private function createReflectionClass(string $name, string $parentName): ReflectionClass diff --git a/library/Rules/Between.php b/library/Rules/Between.php index 0c3ef8590..a5e138fdd 100644 --- a/library/Rules/Between.php +++ b/library/Rules/Between.php @@ -21,9 +21,6 @@ final class Between extends AbstractEnvelope { use CanCompareValues; - /** - * @throws ComponentException - */ public function __construct(mixed $minValue, mixed $maxValue) { if ($this->toComparable($minValue) >= $this->toComparable($maxValue)) { diff --git a/library/Rules/Charset.php b/library/Rules/Charset.php index fe2d9f179..9bcfa7404 100644 --- a/library/Rules/Charset.php +++ b/library/Rules/Charset.php @@ -28,9 +28,6 @@ final class Charset extends AbstractRule */ private readonly array $charset; - /** - * @throws ComponentException - */ public function __construct(string ...$charset) { $available = mb_list_encodings(); diff --git a/library/Rules/CountryCode.php b/library/Rules/CountryCode.php index 2634e0cda..6427b4a36 100644 --- a/library/Rules/CountryCode.php +++ b/library/Rules/CountryCode.php @@ -323,9 +323,6 @@ final class CountryCode extends AbstractSearcher // end of auto-generated code ]; - /** - * @throws ComponentException If $set is not a valid set - */ public function __construct( private readonly string $set = self::ALPHA2 ) { diff --git a/library/Rules/CreditCard.php b/library/Rules/CreditCard.php index ff45c50b6..bd0624c7d 100644 --- a/library/Rules/CreditCard.php +++ b/library/Rules/CreditCard.php @@ -60,9 +60,6 @@ final class CreditCard extends AbstractRule self::RUPAY => '/^6(?!011)(?:0[0-9]{14}|52[12][0-9]{12})$/', ]; - /** - * @throws ComponentException - */ public function __construct( private readonly string $brand = self::ANY ) { diff --git a/library/Rules/Date.php b/library/Rules/Date.php index 21be54199..5a488ae99 100644 --- a/library/Rules/Date.php +++ b/library/Rules/Date.php @@ -27,9 +27,6 @@ final class Date extends AbstractRule { use CanValidateDateTime; - /** - * @throws ComponentException - */ public function __construct( private readonly string $format = 'Y-m-d' ) { diff --git a/library/Rules/FilterVar.php b/library/Rules/FilterVar.php index 3a3ad91a8..7173b5d67 100644 --- a/library/Rules/FilterVar.php +++ b/library/Rules/FilterVar.php @@ -43,9 +43,6 @@ final class FilterVar extends AbstractEnvelope FILTER_VALIDATE_URL => 'is_string', ]; - /** - * @throws ComponentException - */ public function __construct(int $filter, mixed $options = null) { if (!array_key_exists($filter, self::ALLOWED_FILTERS)) { diff --git a/library/Rules/Ip.php b/library/Rules/Ip.php index 5b8ca4569..f3d78f77d 100644 --- a/library/Rules/Ip.php +++ b/library/Rules/Ip.php @@ -49,9 +49,6 @@ final class Ip extends AbstractRule private ?string $mask = null; - /** - * @throws ComponentException In case the range is invalid - */ public function __construct(string $range = '*', private ?int $options = null) { $this->parseRange($range); diff --git a/library/Rules/KeySet.php b/library/Rules/KeySet.php index 04b14b306..ca66b705b 100644 --- a/library/Rules/KeySet.php +++ b/library/Rules/KeySet.php @@ -124,9 +124,6 @@ public function getParams(): array ]; } - /** - * @throws ComponentException - */ private function getKeyRule(Validatable $validatable): Key { if ($validatable instanceof Key) { diff --git a/library/Rules/LanguageCode.php b/library/Rules/LanguageCode.php index a67f26d18..c4b8d7720 100644 --- a/library/Rules/LanguageCode.php +++ b/library/Rules/LanguageCode.php @@ -522,9 +522,6 @@ final class LanguageCode extends AbstractEnvelope // phpcs:enable Squiz.PHP.CommentedOutCode.Found ]; - /** - * @throws ComponentException - */ public function __construct(string $set = self::ALPHA2) { $index = array_search($set, self::AVAILABLE_SETS, true); diff --git a/library/Rules/Length.php b/library/Rules/Length.php index 9a30acb44..c137dd966 100644 --- a/library/Rules/Length.php +++ b/library/Rules/Length.php @@ -61,9 +61,6 @@ final class Length extends AbstractRule public const TEMPLATE_LOWER_INCLUSIVE = 'lower_inclusive'; public const TEMPLATE_BOTH = 'both'; - /** - * @throws ComponentException - */ public function __construct( private readonly ?int $minValue = null, private readonly ?int $maxValue = null, diff --git a/library/Rules/Time.php b/library/Rules/Time.php index 468bd269f..a2ff37e57 100644 --- a/library/Rules/Time.php +++ b/library/Rules/Time.php @@ -27,9 +27,6 @@ final class Time extends AbstractRule { use CanValidateDateTime; - /** - * @throws ComponentException - */ public function __construct( private readonly string $format = 'H:i:s' ) { diff --git a/library/Rules/Type.php b/library/Rules/Type.php index 395844e39..acbe849b3 100644 --- a/library/Rules/Type.php +++ b/library/Rules/Type.php @@ -39,9 +39,6 @@ final class Type extends AbstractRule 'string' => 'string', ]; - /** - * @throws ComponentException When $type is not a valid one - */ public function __construct( private readonly string $type ) { diff --git a/library/Rules/Url.php b/library/Rules/Url.php index 74519b386..b484cb60e 100644 --- a/library/Rules/Url.php +++ b/library/Rules/Url.php @@ -10,7 +10,6 @@ namespace Respect\Validation\Rules; use Respect\Validation\Attributes\Template; -use Respect\Validation\Exceptions\ComponentException; use const FILTER_VALIDATE_URL; @@ -20,9 +19,6 @@ )] final class Url extends AbstractEnvelope { - /** - * @throws ComponentException - */ public function __construct() { parent::__construct(new FilterVar(FILTER_VALIDATE_URL)); diff --git a/library/Rules/Uuid.php b/library/Rules/Uuid.php index e169422cb..bd79755ff 100644 --- a/library/Rules/Uuid.php +++ b/library/Rules/Uuid.php @@ -32,9 +32,6 @@ final class Uuid extends AbstractRule private const PATTERN_FORMAT = '/^[0-9a-f]{8}-[0-9a-f]{4}-%s[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i'; - /** - * @throws ComponentException when the version is not valid - */ public function __construct( private readonly ?int $version = null ) { diff --git a/library/Rules/VideoUrl.php b/library/Rules/VideoUrl.php index 20f889dc6..ba6421281 100644 --- a/library/Rules/VideoUrl.php +++ b/library/Rules/VideoUrl.php @@ -40,9 +40,6 @@ final class VideoUrl extends AbstractRule // phpcs:enable Generic.Files.LineLength.TooLong ]; - /** - * @throws ComponentException when the given service is not supported - */ public function __construct( private readonly ?string $service = null ) { diff --git a/library/Validator.php b/library/Validator.php index 28b022f03..1b971664c 100644 --- a/library/Validator.php +++ b/library/Validator.php @@ -11,7 +11,6 @@ use Respect\Validation\Attributes\ExceptionClass; use Respect\Validation\Attributes\Template; -use Respect\Validation\Exceptions\ComponentException; use Respect\Validation\Exceptions\NestedValidationException; use Respect\Validation\Exceptions\ValidationException; use Respect\Validation\Rules\AllOf; @@ -57,8 +56,6 @@ public function check(mixed $input): void /** * @param mixed[] $arguments - * - * @throws ComponentException */ public static function __callStatic(string $ruleName, array $arguments): self { @@ -67,8 +64,6 @@ public static function __callStatic(string $ruleName, array $arguments): self /** * @param mixed[] $arguments - * - * @throws ComponentException */ public function __call(string $ruleName, array $arguments): self {