Skip to content

Commit

Permalink
Remove "@throws" annotations
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
henriquemoody committed Jan 29, 2024
1 parent b7c4189 commit 84f1d32
Show file tree
Hide file tree
Showing 17 changed files with 0 additions and 58 deletions.
7 changes: 0 additions & 7 deletions library/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public function withParameterStringifier(ParameterStringifier $parameterStringif

/**
* @param mixed[] $arguments
*
* @throws ComponentException
*/
public function rule(string $ruleName, array $arguments = []): Validatable
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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<ValidationException|Validatable|object>
*/
private function createReflectionClass(string $name, string $parentName): ReflectionClass
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/Between.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/Charset.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ final class Charset extends AbstractRule
*/
private readonly array $charset;

/**
* @throws ComponentException
*/
public function __construct(string ...$charset)
{
$available = mb_list_encodings();
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/CountryCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ final class Date extends AbstractRule
{
use CanValidateDateTime;

/**
* @throws ComponentException
*/
public function __construct(
private readonly string $format = 'Y-m-d'
) {
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/FilterVar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/Ip.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/KeySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ public function getParams(): array
];
}

/**
* @throws ComponentException
*/
private function getKeyRule(Validatable $validatable): Key
{
if ($validatable instanceof Key) {
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/LanguageCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/Length.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ final class Time extends AbstractRule
{
use CanValidateDateTime;

/**
* @throws ComponentException
*/
public function __construct(
private readonly string $format = 'H:i:s'
) {
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
4 changes: 0 additions & 4 deletions library/Rules/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace Respect\Validation\Rules;

use Respect\Validation\Attributes\Template;
use Respect\Validation\Exceptions\ComponentException;

use const FILTER_VALIDATE_URL;

Expand All @@ -20,9 +19,6 @@
)]
final class Url extends AbstractEnvelope
{
/**
* @throws ComponentException
*/
public function __construct()
{
parent::__construct(new FilterVar(FILTER_VALIDATE_URL));
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/Uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
3 changes: 0 additions & 3 deletions library/Rules/VideoUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
5 changes: 0 additions & 5 deletions library/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,8 +56,6 @@ public function check(mixed $input): void

/**
* @param mixed[] $arguments
*
* @throws ComponentException
*/
public static function __callStatic(string $ruleName, array $arguments): self
{
Expand All @@ -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
{
Expand Down

0 comments on commit 84f1d32

Please sign in to comment.