diff --git a/composer.json b/composer.json index c6e89c95..b185ed35 100644 --- a/composer.json +++ b/composer.json @@ -38,10 +38,10 @@ "phpunit/phpunit": "^12.5", "psr/http-message": "^1.0 || ^2.0", "ramsey/uuid": "^4", - "respect/coding-standard": "^4.0", + "respect/coding-standard": "^5.0", "sokil/php-isocodes": "^4.2.1", "sokil/php-isocodes-db-only": "^4.0", - "squizlabs/php_codesniffer": "^3.8", + "squizlabs/php_codesniffer": "^4.0", "symfony/var-exporter": "^6.4 || ^7.0" }, "suggest": { diff --git a/library/Exceptions/InvalidRuleConstructorException.php b/library/Exceptions/InvalidRuleConstructorException.php index 0a10fea5..2f9b404f 100644 --- a/library/Exceptions/InvalidRuleConstructorException.php +++ b/library/Exceptions/InvalidRuleConstructorException.php @@ -40,7 +40,7 @@ final class InvalidRuleConstructorException extends ComponentException implement return implode(count($items) > 2 ? ', ' : ' ', $items); }, $arguments, - ) + ), )); } } diff --git a/library/Exceptions/MissingComposerDependencyException.php b/library/Exceptions/MissingComposerDependencyException.php index 5f80d1ae..960f223a 100644 --- a/library/Exceptions/MissingComposerDependencyException.php +++ b/library/Exceptions/MissingComposerDependencyException.php @@ -19,7 +19,7 @@ final class MissingComposerDependencyException extends ComponentException implem parent::__construct(sprintf( '%s. Run `composer require %s` to fix this issue.', $message, - implode(' ', $dependencies) + implode(' ', $dependencies), )); } } diff --git a/library/Exceptions/ValidationException.php b/library/Exceptions/ValidationException.php index 226c1709..5e38c76a 100644 --- a/library/Exceptions/ValidationException.php +++ b/library/Exceptions/ValidationException.php @@ -19,7 +19,7 @@ final class ValidationException extends InvalidArgumentException implements Exce { /** * @param array $messages - * @param array $ignoredBacktracePaths + * @param array $ignoredBacktracePaths */ public function __construct( string $message, @@ -28,6 +28,7 @@ final class ValidationException extends InvalidArgumentException implements Exce array $ignoredBacktracePaths = [], ) { $this->overwriteFileAndLine($ignoredBacktracePaths); + parent::__construct($message); } diff --git a/library/Factory.php b/library/Factory.php index 6c8d0ef1..71a1cb0f 100644 --- a/library/Factory.php +++ b/library/Factory.php @@ -24,13 +24,11 @@ use function ucfirst; final class Factory { - /** - * @var string[] - */ + /** @var string[] */ private array $rulesNamespaces = ['Respect\\Validation\\Rules']; public function __construct( - private readonly Transformer $transformer = new Prefix() + private readonly Transformer $transformer = new Prefix(), ) { } @@ -42,9 +40,7 @@ final class Factory return $clone; } - /** - * @param mixed[] $arguments - */ + /** @param mixed[] $arguments */ public function rule(string $ruleName, array $arguments = []): Rule { return $this->createRuleSpec($this->transformer->transform(new RuleSpec($ruleName, $arguments))); @@ -60,9 +56,7 @@ final class Factory return $rule; } - /** - * @param mixed[] $arguments - */ + /** @param mixed[] $arguments */ private function createRule(string $ruleName, array $arguments = []): Rule { foreach ($this->rulesNamespaces as $namespace) { @@ -72,7 +66,7 @@ final class Factory $reflection = new ReflectionClass($name); if (!$reflection->isSubclassOf(Rule::class)) { throw new InvalidClassException( - sprintf('"%s" must be an instance of "%s"', $name, Rule::class) + sprintf('"%s" must be an instance of "%s"', $name, Rule::class), ); } diff --git a/library/Helpers/CanValidateDateTime.php b/library/Helpers/CanValidateDateTime.php index aebc0776..50248011 100644 --- a/library/Helpers/CanValidateDateTime.php +++ b/library/Helpers/CanValidateDateTime.php @@ -35,7 +35,7 @@ trait CanValidateDateTime $formattedDate = DateTime::createFromFormat( $format, $value, - new DateTimeZone(date_default_timezone_get()) + new DateTimeZone(date_default_timezone_get()), ); if ($formattedDate === false || $value !== $formattedDate->format($format)) { @@ -48,9 +48,7 @@ trait CanValidateDateTime return true; } - /** - * @param mixed[] $info - */ + /** @param mixed[] $info */ private function isDateTimeParsable(array $info): bool { return $info['error_count'] === 0 && $info['warning_count'] === 0; @@ -61,9 +59,7 @@ trait CanValidateDateTime return preg_match('/[djSFmMnYy]/', $format) > 0; } - /** - * @param mixed[] $info - */ + /** @param mixed[] $info */ private function isDateInformation(array $info): bool { if ($info['day']) { diff --git a/library/Helpers/DomainInfo.php b/library/Helpers/DomainInfo.php index 8a6ab07a..acb1b6b0 100644 --- a/library/Helpers/DomainInfo.php +++ b/library/Helpers/DomainInfo.php @@ -14,14 +14,10 @@ use function mb_strtoupper; final class DomainInfo { - /** - * @var mixed[] - */ + /** @var mixed[] */ private readonly array $data; - /** - * @var mixed[] - */ + /** @var mixed[] */ private static array $runtimeCache = []; public function __construct(string $tld) @@ -36,9 +32,7 @@ final class DomainInfo $this->data = static::$runtimeCache[$tld]; } - /** - * @return array - */ + /** @return array */ public function getPublicSuffixes(): array { return $this->data; diff --git a/library/Message/Formatter.php b/library/Message/Formatter.php index 1adf1f61..6b4d6db2 100644 --- a/library/Message/Formatter.php +++ b/library/Message/Formatter.php @@ -13,20 +13,16 @@ use Respect\Validation\Result; interface Formatter { - /** - * @param array $templates - */ + /** @param array $templates */ public function main(Result $result, array $templates, Translator $translator): string; - /** - * @param array $templates - */ + /** @param array $templates */ public function full( Result $result, array $templates, Translator $translator, int $depth = 0, - Result ...$siblings + Result ...$siblings, ): string; /** diff --git a/library/Message/Placeholder/Listed.php b/library/Message/Placeholder/Listed.php index 80ad024a..b6a018ce 100644 --- a/library/Message/Placeholder/Listed.php +++ b/library/Message/Placeholder/Listed.php @@ -14,7 +14,7 @@ final readonly class Listed /** @param array $values */ public function __construct( public array $values, - public string $lastGlue + public string $lastGlue, ) { } } diff --git a/library/Message/Placeholder/Quoted.php b/library/Message/Placeholder/Quoted.php index 6c8e570c..774a24fb 100644 --- a/library/Message/Placeholder/Quoted.php +++ b/library/Message/Placeholder/Quoted.php @@ -12,7 +12,7 @@ namespace Respect\Validation\Message\Placeholder; final readonly class Quoted { public function __construct( - private string $value + private string $value, ) { } diff --git a/library/Message/Renderer.php b/library/Message/Renderer.php index 78187dd3..13656434 100644 --- a/library/Message/Renderer.php +++ b/library/Message/Renderer.php @@ -13,5 +13,5 @@ use Respect\Validation\Result; interface Renderer { - public function render(Result $result, Translator $translator, ?string $template = null): string; + public function render(Result $result, Translator $translator, string|null $template = null): string; } diff --git a/library/Message/StandardFormatter.php b/library/Message/StandardFormatter.php index 9bd59b27..9e9d65e5 100644 --- a/library/Message/StandardFormatter.php +++ b/library/Message/StandardFormatter.php @@ -35,9 +35,7 @@ final readonly class StandardFormatter implements Formatter ) { } - /** - * @param array $templates - */ + /** @param array $templates */ public function main(Result $result, array $templates, Translator $translator): string { $selectedTemplates = $this->selectTemplates($result, $templates); @@ -50,15 +48,13 @@ final readonly class StandardFormatter implements Formatter return $this->renderer->render($this->getTemplated($result, $selectedTemplates), $translator); } - /** - * @param array $templates - */ + /** @param array $templates */ public function full( Result $result, array $templates, Translator $translator, int $depth = 0, - Result ...$siblings + Result ...$siblings, ): string { $selectedTemplates = $this->selectTemplates($result, $templates); $isFinalTemplate = $this->isFinalTemplate($result, $selectedTemplates); @@ -71,7 +67,7 @@ final readonly class StandardFormatter implements Formatter $indentation, $this->renderer->render( $this->getTemplated($depth > 0 ? $result->withDeepestPath() : $result, $selectedTemplates), - $translator + $translator, ), ); $depth++; @@ -80,7 +76,7 @@ final readonly class StandardFormatter implements Formatter if (!$isFinalTemplate) { $results = array_map( fn(Result $child) => $this->resultWithPath($result, $child), - $this->extractDeduplicatedChildren($result) + $this->extractDeduplicatedChildren($result), ); foreach ($results as $child) { $rendered .= $this->full( @@ -88,7 +84,7 @@ final readonly class StandardFormatter implements Formatter $selectedTemplates, $translator, $depth, - ...array_filter($results, static fn (Result $sibling) => $sibling !== $child) + ...array_filter($results, static fn(Result $sibling) => $sibling !== $child), ); $rendered .= PHP_EOL; } @@ -110,7 +106,7 @@ final readonly class StandardFormatter implements Formatter return [ $result->getDeepestPath() ?? $result->id => $this->renderer->render( $this->getTemplated($result->withDeepestPath(), $selectedTemplates), - $translator + $translator, ), ]; } @@ -121,7 +117,7 @@ final readonly class StandardFormatter implements Formatter $messages[$key] = $this->array( $this->resultWithPath($result, $child), $this->selectTemplates($child, $selectedTemplates), - $translator + $translator, ); if (count($messages[$key]) !== 1) { continue; @@ -134,7 +130,7 @@ final readonly class StandardFormatter implements Formatter $self = [ '__root__' => $this->renderer->render( $this->getTemplated($result->withDeepestPath(), $selectedTemplates), - $translator + $translator, ), ]; @@ -169,10 +165,10 @@ final readonly class StandardFormatter implements Formatter $childrenAlwaysVisible = array_filter( $result->children, - fn (Result $child) => $this->isAlwaysVisible($child, ...array_filter( + fn(Result $child) => $this->isAlwaysVisible($child, ...array_filter( $result->children, - static fn (Result $sibling) => $sibling !== $child - )) + static fn(Result $sibling) => $sibling !== $child, + )), ); if (count($childrenAlwaysVisible) !== 1) { return true; @@ -184,11 +180,11 @@ final readonly class StandardFormatter implements Formatter return array_reduce( $siblings, - fn (bool $carry, Result $currentSibling) => $carry || $this->isAlwaysVisible( + fn(bool $carry, Result $currentSibling) => $carry || $this->isAlwaysVisible( $currentSibling, - ...array_filter($siblings, static fn (Result $sibling) => $sibling !== $currentSibling) + ...array_filter($siblings, static fn(Result $sibling) => $sibling !== $currentSibling), ), - true + true, ); } @@ -209,16 +205,14 @@ final readonly class StandardFormatter implements Formatter } throw new ComponentException( - sprintf('Template for "%s" must be a string, %s given', $key, stringify($templates[$key])) + sprintf('Template for "%s" must be a string, %s given', $key, stringify($templates[$key])), ); } return $result; } - /** - * @param array $templates - */ + /** @param array $templates */ private function isFinalTemplate(Result $result, array $templates): bool { $keys = array_filter([$result->path, $result->name, $result->id], static fn($key) => $key !== null); diff --git a/library/Message/StandardRenderer.php b/library/Message/StandardRenderer.php index 969cc5af..890ebc1f 100644 --- a/library/Message/StandardRenderer.php +++ b/library/Message/StandardRenderer.php @@ -33,7 +33,7 @@ final class StandardRenderer implements Renderer ) { } - public function render(Result $result, Translator $translator, ?string $template = null): string + public function render(Result $result, Translator $translator, string|null $template = null): string { $parameters = $result->parameters; $parameters['path'] = $result->path !== null ? Quoted::fromPath($result->path) : null; @@ -51,7 +51,7 @@ final class StandardRenderer implements Renderer return $this->placeholder($matches[1], $parameters[$matches[1]], $translator, $matches[3] ?? null); }, - $translator->translate($template ?? $this->getTemplateMessage($result)) + $translator->translate($template ?? $this->getTemplateMessage($result)), ); if (!$result->hasCustomTemplate() && $result->adjacent !== null) { @@ -74,8 +74,12 @@ final class StandardRenderer implements Renderer return $this->templates[$rule::class] ?? []; } - private function placeholder(string $name, mixed $value, Translator $translator, ?string $modifier = null): string - { + private function placeholder( + string $name, + mixed $value, + Translator $translator, + string|null $modifier = null, + ): string { if ($modifier === 'quote' && is_string($value)) { return $this->placeholder($name, new Quoted($value), $translator); } diff --git a/library/Message/StandardStringifier.php b/library/Message/StandardStringifier.php index 4df97688..68deeb6a 100644 --- a/library/Message/StandardStringifier.php +++ b/library/Message/StandardStringifier.php @@ -36,15 +36,15 @@ use Respect\Validation\Message\Stringifier\QuotedStringifier; final readonly class StandardStringifier implements Stringifier { - private const MAXIMUM_DEPTH = 3; - private const MAXIMUM_NUMBER_OF_ITEMS = 5; - private const MAXIMUM_NUMBER_OF_PROPERTIES = self::MAXIMUM_NUMBER_OF_ITEMS; - private const MAXIMUM_LENGTH = 120; + private const int MAXIMUM_DEPTH = 3; + private const int MAXIMUM_NUMBER_OF_ITEMS = 5; + private const int MAXIMUM_NUMBER_OF_PROPERTIES = self::MAXIMUM_NUMBER_OF_ITEMS; + private const int MAXIMUM_LENGTH = 120; private Stringifier $stringifier; public function __construct( - private Quoter $quoter = new StandardQuoter(self::MAXIMUM_LENGTH) + private Quoter $quoter = new StandardQuoter(self::MAXIMUM_LENGTH), ) { $this->stringifier = $this->createStringifier($quoter); } @@ -78,7 +78,7 @@ final readonly class StandardStringifier implements Stringifier $stringifier, $quoter, self::MAXIMUM_DEPTH, - self::MAXIMUM_NUMBER_OF_PROPERTIES + self::MAXIMUM_NUMBER_OF_PROPERTIES, )); $stringifier->prependStringifier(new EnumerationStringifier($quoter)); $stringifier->prependStringifier(new ObjectWithDebugInfoStringifier($arrayStringifier, $quoter)); diff --git a/library/Message/Stringifier/ListedStringifier.php b/library/Message/Stringifier/ListedStringifier.php index 394fc8c5..d8d26388 100644 --- a/library/Message/Stringifier/ListedStringifier.php +++ b/library/Message/Stringifier/ListedStringifier.php @@ -21,11 +21,11 @@ use function sprintf; final readonly class ListedStringifier implements Stringifier { public function __construct( - private Stringifier $stringifier + private Stringifier $stringifier, ) { } - public function stringify(mixed $raw, int $depth): ?string + public function stringify(mixed $raw, int $depth): string|null { if (!$raw instanceof Listed) { return null; @@ -35,10 +35,11 @@ final readonly class ListedStringifier implements Stringifier return null; } - $strings = array_map(fn ($value) => $this->stringifier->stringify($value, $depth + 1), $raw->values); + $strings = array_map(fn($value) => $this->stringifier->stringify($value, $depth + 1), $raw->values); if (count($strings) < 3) { return implode(sprintf(' %s ', $raw->lastGlue), $strings); } + $lastString = array_pop($strings); return sprintf('%s, %s %s', implode(', ', $strings), $raw->lastGlue, $lastString); diff --git a/library/Message/Stringifier/QuotedStringifier.php b/library/Message/Stringifier/QuotedStringifier.php index 6a5a9564..d592ae2a 100644 --- a/library/Message/Stringifier/QuotedStringifier.php +++ b/library/Message/Stringifier/QuotedStringifier.php @@ -16,11 +16,11 @@ use Respect\Validation\Message\Placeholder\Quoted; final readonly class QuotedStringifier implements Stringifier { public function __construct( - private Quoter $quoter + private Quoter $quoter, ) { } - public function stringify(mixed $raw, int $depth): ?string + public function stringify(mixed $raw, int $depth): string|null { if (!$raw instanceof Quoted) { return null; diff --git a/library/Message/Translator/ArrayTranslator.php b/library/Message/Translator/ArrayTranslator.php index 20c20796..d7b9f866 100644 --- a/library/Message/Translator/ArrayTranslator.php +++ b/library/Message/Translator/ArrayTranslator.php @@ -17,7 +17,7 @@ final readonly class ArrayTranslator implements Translator { /** @param array $messages */ public function __construct( - private array $messages + private array $messages, ) { } diff --git a/library/Mixins/Builder.php b/library/Mixins/Builder.php index 128926cb..e47da52f 100644 --- a/library/Mixins/Builder.php +++ b/library/Mixins/Builder.php @@ -75,41 +75,33 @@ interface Builder extends public static function contains(mixed $containsValue, bool $identical = false): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public static function containsAny(array $needles, bool $identical = false): Chain; public static function control(string ...$additionalChars): Chain; public static function countable(): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public static function countryCode(string $set = 'alpha-2'): Chain; public static function cpf(): Chain; public static function creditCard(string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public static function currencyCode(string $set = 'alpha-3'): Chain; public static function date(string $format = 'Y-m-d'): Chain; - public static function dateTime(?string $format = null): Chain; + public static function dateTime(string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public static function dateTimeDiff( string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public static function decimal(int $decimals): Chain; @@ -176,16 +168,14 @@ interface Builder extends public static function infinite(): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public static function instance(string $class): Chain; public static function intType(): Chain; public static function intVal(): Chain; - public static function ip(string $range = '*', ?int $options = null): Chain; + public static function ip(string $range = '*', int|null $options = null): Chain; public static function isbn(): Chain; @@ -203,14 +193,10 @@ interface Builder extends public static function keySet(Rule $rule, Rule ...$rules): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public static function languageCode(string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public static function lazy(callable $ruleCreator): Chain; public static function leapDate(string $format): Chain; @@ -281,7 +267,7 @@ interface Builder extends public static function pesel(): Chain; - public static function phone(?string $countryCode = null): Chain; + public static function phone(string|null $countryCode = null): Chain; public static function phpLabel(): Chain; @@ -319,9 +305,7 @@ interface Builder extends public static function scalarVal(): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public static function size(string $unit, Rule $rule): Chain; public static function slug(): Chain; @@ -338,16 +322,12 @@ interface Builder extends public static function subdivisionCode(string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public static function subset(array $superset): Chain; public static function symbolicLink(): Chain; - /** - * @param array $parameters - */ + /** @param array $parameters */ public static function templated(Rule $rule, string $template, array $parameters = []): Chain; public static function time(string $format = 'H:i:s'): Chain; @@ -366,15 +346,15 @@ interface Builder extends public static function url(): Chain; - public static function uuid(?int $version = null): Chain; + public static function uuid(int|null $version = null): Chain; public static function version(): Chain; - public static function videoUrl(?string $service = null): Chain; + public static function videoUrl(string|null $service = null): Chain; public static function vowel(string ...$additionalChars): Chain; - public static function when(Rule $when, Rule $then, ?Rule $else = null): Chain; + public static function when(Rule $when, Rule $then, Rule|null $else = null): Chain; public static function writable(): Chain; diff --git a/library/Mixins/Chain.php b/library/Mixins/Chain.php index 45f69ef4..d8088808 100644 --- a/library/Mixins/Chain.php +++ b/library/Mixins/Chain.php @@ -13,9 +13,7 @@ use DateTimeImmutable; use Respect\Validation\Rule; use Respect\Validation\Validator; -/** - * @mixin Validator - */ +/** @mixin Validator */ interface Chain extends Rule, KeyChain, @@ -80,41 +78,33 @@ interface Chain extends public function contains(mixed $containsValue, bool $identical = false): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public function containsAny(array $needles, bool $identical = false): Chain; public function control(string ...$additionalChars): Chain; public function countable(): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public function countryCode(string $set = 'alpha-2'): Chain; public function cpf(): Chain; public function creditCard(string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public function currencyCode(string $set = 'alpha-3'): Chain; public function date(string $format = 'Y-m-d'): Chain; - public function dateTime(?string $format = null): Chain; + public function dateTime(string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public function dateTimeDiff( string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public function decimal(int $decimals): Chain; @@ -181,16 +171,14 @@ interface Chain extends public function infinite(): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public function instance(string $class): Chain; public function intType(): Chain; public function intVal(): Chain; - public function ip(string $range = '*', ?int $options = null): Chain; + public function ip(string $range = '*', int|null $options = null): Chain; public function isbn(): Chain; @@ -208,14 +196,10 @@ interface Chain extends public function keySet(Rule $rule, Rule ...$rules): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public function languageCode(string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public function lazy(callable $ruleCreator): Chain; public function leapDate(string $format): Chain; @@ -286,7 +270,7 @@ interface Chain extends public function pesel(): Chain; - public function phone(?string $countryCode = null): Chain; + public function phone(string|null $countryCode = null): Chain; public function phpLabel(): Chain; @@ -324,9 +308,7 @@ interface Chain extends public function scalarVal(): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public function size(string $unit, Rule $rule): Chain; public function slug(): Chain; @@ -343,16 +325,12 @@ interface Chain extends public function subdivisionCode(string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public function subset(array $superset): Chain; public function symbolicLink(): Chain; - /** - * @param array $parameters - */ + /** @param array $parameters */ public function templated(Rule $rule, string $template, array $parameters = []): Chain; public function time(string $format = 'H:i:s'): Chain; @@ -371,15 +349,15 @@ interface Chain extends public function url(): Chain; - public function uuid(?int $version = null): Chain; + public function uuid(int|null $version = null): Chain; public function version(): Chain; - public function videoUrl(?string $service = null): Chain; + public function videoUrl(string|null $service = null): Chain; public function vowel(string ...$additionalChars): Chain; - public function when(Rule $when, Rule $then, ?Rule $else = null): Chain; + public function when(Rule $when, Rule $then, Rule|null $else = null): Chain; public function writable(): Chain; diff --git a/library/Mixins/KeyBuilder.php b/library/Mixins/KeyBuilder.php index 86c20da8..9e45e5bd 100644 --- a/library/Mixins/KeyBuilder.php +++ b/library/Mixins/KeyBuilder.php @@ -66,42 +66,34 @@ interface KeyBuilder public static function keyContains(int|string $key, mixed $containsValue, bool $identical = false): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public static function keyContainsAny(int|string $key, array $needles, bool $identical = false): Chain; public static function keyControl(int|string $key, string ...$additionalChars): Chain; public static function keyCountable(int|string $key): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public static function keyCountryCode(int|string $key, string $set = 'alpha-2'): Chain; public static function keyCpf(int|string $key): Chain; public static function keyCreditCard(int|string $key, string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public static function keyCurrencyCode(int|string $key, string $set = 'alpha-3'): Chain; public static function keyDate(int|string $key, string $format = 'Y-m-d'): Chain; - public static function keyDateTime(int|string $key, ?string $format = null): Chain; + public static function keyDateTime(int|string $key, string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public static function keyDateTimeDiff( int|string $key, string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public static function keyDecimal(int|string $key, int $decimals): Chain; @@ -166,16 +158,14 @@ interface KeyBuilder public static function keyInfinite(int|string $key): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public static function keyInstance(int|string $key, string $class): Chain; public static function keyIntType(int|string $key): Chain; public static function keyIntVal(int|string $key): Chain; - public static function keyIp(int|string $key, string $range = '*', ?int $options = null): Chain; + public static function keyIp(int|string $key, string $range = '*', int|null $options = null): Chain; public static function keyIsbn(int|string $key): Chain; @@ -185,14 +175,10 @@ interface KeyBuilder public static function keyJson(int|string $key): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public static function keyLanguageCode(int|string $key, string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public static function keyLazy(int|string $key, callable $ruleCreator): Chain; public static function keyLeapDate(int|string $key, string $format): Chain; @@ -259,7 +245,7 @@ interface KeyBuilder public static function keyPesel(int|string $key): Chain; - public static function keyPhone(int|string $key, ?string $countryCode = null): Chain; + public static function keyPhone(int|string $key, string|null $countryCode = null): Chain; public static function keyPhpLabel(int|string $key): Chain; @@ -291,9 +277,7 @@ interface KeyBuilder public static function keyScalarVal(int|string $key): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public static function keySize(int|string $key, string $unit, Rule $rule): Chain; public static function keySlug(int|string $key): Chain; @@ -310,9 +294,7 @@ interface KeyBuilder public static function keySubdivisionCode(int|string $key, string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public static function keySubset(int|string $key, array $superset): Chain; public static function keySymbolicLink(int|string $key): Chain; @@ -331,15 +313,15 @@ interface KeyBuilder public static function keyUrl(int|string $key): Chain; - public static function keyUuid(int|string $key, ?int $version = null): Chain; + public static function keyUuid(int|string $key, int|null $version = null): Chain; public static function keyVersion(int|string $key): Chain; - public static function keyVideoUrl(int|string $key, ?string $service = null): Chain; + public static function keyVideoUrl(int|string $key, string|null $service = null): Chain; public static function keyVowel(int|string $key, string ...$additionalChars): Chain; - public static function keyWhen(int|string $key, Rule $when, Rule $then, ?Rule $else = null): Chain; + public static function keyWhen(int|string $key, Rule $when, Rule $then, Rule|null $else = null): Chain; public static function keyWritable(int|string $key): Chain; diff --git a/library/Mixins/KeyChain.php b/library/Mixins/KeyChain.php index 8508340b..2549ffca 100644 --- a/library/Mixins/KeyChain.php +++ b/library/Mixins/KeyChain.php @@ -66,42 +66,34 @@ interface KeyChain public function keyContains(int|string $key, mixed $containsValue, bool $identical = false): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public function keyContainsAny(int|string $key, array $needles, bool $identical = false): Chain; public function keyControl(int|string $key, string ...$additionalChars): Chain; public function keyCountable(int|string $key): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public function keyCountryCode(int|string $key, string $set = 'alpha-2'): Chain; public function keyCpf(int|string $key): Chain; public function keyCreditCard(int|string $key, string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public function keyCurrencyCode(int|string $key, string $set = 'alpha-3'): Chain; public function keyDate(int|string $key, string $format = 'Y-m-d'): Chain; - public function keyDateTime(int|string $key, ?string $format = null): Chain; + public function keyDateTime(int|string $key, string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public function keyDateTimeDiff( int|string $key, string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public function keyDecimal(int|string $key, int $decimals): Chain; @@ -166,16 +158,14 @@ interface KeyChain public function keyInfinite(int|string $key): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public function keyInstance(int|string $key, string $class): Chain; public function keyIntType(int|string $key): Chain; public function keyIntVal(int|string $key): Chain; - public function keyIp(int|string $key, string $range = '*', ?int $options = null): Chain; + public function keyIp(int|string $key, string $range = '*', int|null $options = null): Chain; public function keyIsbn(int|string $key): Chain; @@ -185,14 +175,10 @@ interface KeyChain public function keyJson(int|string $key): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public function keyLanguageCode(int|string $key, string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public function keyLazy(int|string $key, callable $ruleCreator): Chain; public function keyLeapDate(int|string $key, string $format): Chain; @@ -259,7 +245,7 @@ interface KeyChain public function keyPesel(int|string $key): Chain; - public function keyPhone(int|string $key, ?string $countryCode = null): Chain; + public function keyPhone(int|string $key, string|null $countryCode = null): Chain; public function keyPhpLabel(int|string $key): Chain; @@ -291,9 +277,7 @@ interface KeyChain public function keyScalarVal(int|string $key): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public function keySize(int|string $key, string $unit, Rule $rule): Chain; public function keySlug(int|string $key): Chain; @@ -310,9 +294,7 @@ interface KeyChain public function keySubdivisionCode(int|string $key, string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public function keySubset(int|string $key, array $superset): Chain; public function keySymbolicLink(int|string $key): Chain; @@ -331,15 +313,15 @@ interface KeyChain public function keyUrl(int|string $key): Chain; - public function keyUuid(int|string $key, ?int $version = null): Chain; + public function keyUuid(int|string $key, int|null $version = null): Chain; public function keyVersion(int|string $key): Chain; - public function keyVideoUrl(int|string $key, ?string $service = null): Chain; + public function keyVideoUrl(int|string $key, string|null $service = null): Chain; public function keyVowel(int|string $key, string ...$additionalChars): Chain; - public function keyWhen(int|string $key, Rule $when, Rule $then, ?Rule $else = null): Chain; + public function keyWhen(int|string $key, Rule $when, Rule $then, Rule|null $else = null): Chain; public function keyWritable(int|string $key): Chain; diff --git a/library/Mixins/NotBuilder.php b/library/Mixins/NotBuilder.php index 2c7f1471..56276d13 100644 --- a/library/Mixins/NotBuilder.php +++ b/library/Mixins/NotBuilder.php @@ -65,41 +65,33 @@ interface NotBuilder public static function notContains(mixed $containsValue, bool $identical = false): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public static function notContainsAny(array $needles, bool $identical = false): Chain; public static function notControl(string ...$additionalChars): Chain; public static function notCountable(): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public static function notCountryCode(string $set = 'alpha-2'): Chain; public static function notCpf(): Chain; public static function notCreditCard(string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public static function notCurrencyCode(string $set = 'alpha-3'): Chain; public static function notDate(string $format = 'Y-m-d'): Chain; - public static function notDateTime(?string $format = null): Chain; + public static function notDateTime(string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public static function notDateTimeDiff( string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public static function notDecimal(int $decimals): Chain; @@ -166,16 +158,14 @@ interface NotBuilder public static function notInfinite(): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public static function notInstance(string $class): Chain; public static function notIntType(): Chain; public static function notIntVal(): Chain; - public static function notIp(string $range = '*', ?int $options = null): Chain; + public static function notIp(string $range = '*', int|null $options = null): Chain; public static function notIsbn(): Chain; @@ -193,14 +183,10 @@ interface NotBuilder public static function notKeySet(Rule $rule, Rule ...$rules): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public static function notLanguageCode(string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public static function notLazy(callable $ruleCreator): Chain; public static function notLeapDate(string $format): Chain; @@ -257,7 +243,7 @@ interface NotBuilder public static function notPesel(): Chain; - public static function notPhone(?string $countryCode = null): Chain; + public static function notPhone(string|null $countryCode = null): Chain; public static function notPhpLabel(): Chain; @@ -295,9 +281,7 @@ interface NotBuilder public static function notScalarVal(): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public static function notSize(string $unit, Rule $rule): Chain; public static function notSlug(): Chain; @@ -314,9 +298,7 @@ interface NotBuilder public static function notSubdivisionCode(string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public static function notSubset(array $superset): Chain; public static function notSymbolicLink(): Chain; @@ -335,15 +317,15 @@ interface NotBuilder public static function notUrl(): Chain; - public static function notUuid(?int $version = null): Chain; + public static function notUuid(int|null $version = null): Chain; public static function notVersion(): Chain; - public static function notVideoUrl(?string $service = null): Chain; + public static function notVideoUrl(string|null $service = null): Chain; public static function notVowel(string ...$additionalChars): Chain; - public static function notWhen(Rule $when, Rule $then, ?Rule $else = null): Chain; + public static function notWhen(Rule $when, Rule $then, Rule|null $else = null): Chain; public static function notWritable(): Chain; diff --git a/library/Mixins/NotChain.php b/library/Mixins/NotChain.php index b4a00a33..5839a567 100644 --- a/library/Mixins/NotChain.php +++ b/library/Mixins/NotChain.php @@ -65,41 +65,33 @@ interface NotChain public function notContains(mixed $containsValue, bool $identical = false): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public function notContainsAny(array $needles, bool $identical = false): Chain; public function notControl(string ...$additionalChars): Chain; public function notCountable(): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public function notCountryCode(string $set = 'alpha-2'): Chain; public function notCpf(): Chain; public function notCreditCard(string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public function notCurrencyCode(string $set = 'alpha-3'): Chain; public function notDate(string $format = 'Y-m-d'): Chain; - public function notDateTime(?string $format = null): Chain; + public function notDateTime(string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public function notDateTimeDiff( string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public function notDecimal(int $decimals): Chain; @@ -166,16 +158,14 @@ interface NotChain public function notInfinite(): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public function notInstance(string $class): Chain; public function notIntType(): Chain; public function notIntVal(): Chain; - public function notIp(string $range = '*', ?int $options = null): Chain; + public function notIp(string $range = '*', int|null $options = null): Chain; public function notIsbn(): Chain; @@ -193,14 +183,10 @@ interface NotChain public function notKeySet(Rule $rule, Rule ...$rules): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public function notLanguageCode(string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public function notLazy(callable $ruleCreator): Chain; public function notLeapDate(string $format): Chain; @@ -257,7 +243,7 @@ interface NotChain public function notPesel(): Chain; - public function notPhone(?string $countryCode = null): Chain; + public function notPhone(string|null $countryCode = null): Chain; public function notPhpLabel(): Chain; @@ -295,9 +281,7 @@ interface NotChain public function notScalarVal(): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public function notSize(string $unit, Rule $rule): Chain; public function notSlug(): Chain; @@ -314,9 +298,7 @@ interface NotChain public function notSubdivisionCode(string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public function notSubset(array $superset): Chain; public function notSymbolicLink(): Chain; @@ -335,15 +317,15 @@ interface NotChain public function notUrl(): Chain; - public function notUuid(?int $version = null): Chain; + public function notUuid(int|null $version = null): Chain; public function notVersion(): Chain; - public function notVideoUrl(?string $service = null): Chain; + public function notVideoUrl(string|null $service = null): Chain; public function notVowel(string ...$additionalChars): Chain; - public function notWhen(Rule $when, Rule $then, ?Rule $else = null): Chain; + public function notWhen(Rule $when, Rule $then, Rule|null $else = null): Chain; public function notWritable(): Chain; diff --git a/library/Mixins/NullOrBuilder.php b/library/Mixins/NullOrBuilder.php index 4c955e3c..e98a1fac 100644 --- a/library/Mixins/NullOrBuilder.php +++ b/library/Mixins/NullOrBuilder.php @@ -67,41 +67,33 @@ interface NullOrBuilder public static function nullOrContains(mixed $containsValue, bool $identical = false): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public static function nullOrContainsAny(array $needles, bool $identical = false): Chain; public static function nullOrControl(string ...$additionalChars): Chain; public static function nullOrCountable(): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public static function nullOrCountryCode(string $set = 'alpha-2'): Chain; public static function nullOrCpf(): Chain; public static function nullOrCreditCard(string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public static function nullOrCurrencyCode(string $set = 'alpha-3'): Chain; public static function nullOrDate(string $format = 'Y-m-d'): Chain; - public static function nullOrDateTime(?string $format = null): Chain; + public static function nullOrDateTime(string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public static function nullOrDateTimeDiff( string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public static function nullOrDecimal(int $decimals): Chain; @@ -168,16 +160,14 @@ interface NullOrBuilder public static function nullOrInfinite(): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public static function nullOrInstance(string $class): Chain; public static function nullOrIntType(): Chain; public static function nullOrIntVal(): Chain; - public static function nullOrIp(string $range = '*', ?int $options = null): Chain; + public static function nullOrIp(string $range = '*', int|null $options = null): Chain; public static function nullOrIsbn(): Chain; @@ -195,14 +185,10 @@ interface NullOrBuilder public static function nullOrKeySet(Rule $rule, Rule ...$rules): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public static function nullOrLanguageCode(string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public static function nullOrLazy(callable $ruleCreator): Chain; public static function nullOrLeapDate(string $format): Chain; @@ -267,7 +253,7 @@ interface NullOrBuilder public static function nullOrPesel(): Chain; - public static function nullOrPhone(?string $countryCode = null): Chain; + public static function nullOrPhone(string|null $countryCode = null): Chain; public static function nullOrPhpLabel(): Chain; @@ -305,9 +291,7 @@ interface NullOrBuilder public static function nullOrScalarVal(): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public static function nullOrSize(string $unit, Rule $rule): Chain; public static function nullOrSlug(): Chain; @@ -324,9 +308,7 @@ interface NullOrBuilder public static function nullOrSubdivisionCode(string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public static function nullOrSubset(array $superset): Chain; public static function nullOrSymbolicLink(): Chain; @@ -345,15 +327,15 @@ interface NullOrBuilder public static function nullOrUrl(): Chain; - public static function nullOrUuid(?int $version = null): Chain; + public static function nullOrUuid(int|null $version = null): Chain; public static function nullOrVersion(): Chain; - public static function nullOrVideoUrl(?string $service = null): Chain; + public static function nullOrVideoUrl(string|null $service = null): Chain; public static function nullOrVowel(string ...$additionalChars): Chain; - public static function nullOrWhen(Rule $when, Rule $then, ?Rule $else = null): Chain; + public static function nullOrWhen(Rule $when, Rule $then, Rule|null $else = null): Chain; public static function nullOrWritable(): Chain; diff --git a/library/Mixins/NullOrChain.php b/library/Mixins/NullOrChain.php index b3f8b316..c794ffa1 100644 --- a/library/Mixins/NullOrChain.php +++ b/library/Mixins/NullOrChain.php @@ -67,41 +67,33 @@ interface NullOrChain public function nullOrContains(mixed $containsValue, bool $identical = false): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public function nullOrContainsAny(array $needles, bool $identical = false): Chain; public function nullOrControl(string ...$additionalChars): Chain; public function nullOrCountable(): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public function nullOrCountryCode(string $set = 'alpha-2'): Chain; public function nullOrCpf(): Chain; public function nullOrCreditCard(string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public function nullOrCurrencyCode(string $set = 'alpha-3'): Chain; public function nullOrDate(string $format = 'Y-m-d'): Chain; - public function nullOrDateTime(?string $format = null): Chain; + public function nullOrDateTime(string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public function nullOrDateTimeDiff( string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public function nullOrDecimal(int $decimals): Chain; @@ -168,16 +160,14 @@ interface NullOrChain public function nullOrInfinite(): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public function nullOrInstance(string $class): Chain; public function nullOrIntType(): Chain; public function nullOrIntVal(): Chain; - public function nullOrIp(string $range = '*', ?int $options = null): Chain; + public function nullOrIp(string $range = '*', int|null $options = null): Chain; public function nullOrIsbn(): Chain; @@ -195,14 +185,10 @@ interface NullOrChain public function nullOrKeySet(Rule $rule, Rule ...$rules): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public function nullOrLanguageCode(string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public function nullOrLazy(callable $ruleCreator): Chain; public function nullOrLeapDate(string $format): Chain; @@ -267,7 +253,7 @@ interface NullOrChain public function nullOrPesel(): Chain; - public function nullOrPhone(?string $countryCode = null): Chain; + public function nullOrPhone(string|null $countryCode = null): Chain; public function nullOrPhpLabel(): Chain; @@ -305,9 +291,7 @@ interface NullOrChain public function nullOrScalarVal(): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public function nullOrSize(string $unit, Rule $rule): Chain; public function nullOrSlug(): Chain; @@ -324,9 +308,7 @@ interface NullOrChain public function nullOrSubdivisionCode(string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public function nullOrSubset(array $superset): Chain; public function nullOrSymbolicLink(): Chain; @@ -345,15 +327,15 @@ interface NullOrChain public function nullOrUrl(): Chain; - public function nullOrUuid(?int $version = null): Chain; + public function nullOrUuid(int|null $version = null): Chain; public function nullOrVersion(): Chain; - public function nullOrVideoUrl(?string $service = null): Chain; + public function nullOrVideoUrl(string|null $service = null): Chain; public function nullOrVowel(string ...$additionalChars): Chain; - public function nullOrWhen(Rule $when, Rule $then, ?Rule $else = null): Chain; + public function nullOrWhen(Rule $when, Rule $then, Rule|null $else = null): Chain; public function nullOrWritable(): Chain; diff --git a/library/Mixins/PropertyBuilder.php b/library/Mixins/PropertyBuilder.php index 1fad5460..d3c94da2 100644 --- a/library/Mixins/PropertyBuilder.php +++ b/library/Mixins/PropertyBuilder.php @@ -70,42 +70,34 @@ interface PropertyBuilder bool $identical = false, ): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public static function propertyContainsAny(string $propertyName, array $needles, bool $identical = false): Chain; public static function propertyControl(string $propertyName, string ...$additionalChars): Chain; public static function propertyCountable(string $propertyName): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public static function propertyCountryCode(string $propertyName, string $set = 'alpha-2'): Chain; public static function propertyCpf(string $propertyName): Chain; public static function propertyCreditCard(string $propertyName, string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public static function propertyCurrencyCode(string $propertyName, string $set = 'alpha-3'): Chain; public static function propertyDate(string $propertyName, string $format = 'Y-m-d'): Chain; - public static function propertyDateTime(string $propertyName, ?string $format = null): Chain; + public static function propertyDateTime(string $propertyName, string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public static function propertyDateTimeDiff( string $propertyName, string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public static function propertyDecimal(string $propertyName, int $decimals): Chain; @@ -170,16 +162,14 @@ interface PropertyBuilder public static function propertyInfinite(string $propertyName): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public static function propertyInstance(string $propertyName, string $class): Chain; public static function propertyIntType(string $propertyName): Chain; public static function propertyIntVal(string $propertyName): Chain; - public static function propertyIp(string $propertyName, string $range = '*', ?int $options = null): Chain; + public static function propertyIp(string $propertyName, string $range = '*', int|null $options = null): Chain; public static function propertyIsbn(string $propertyName): Chain; @@ -189,14 +179,10 @@ interface PropertyBuilder public static function propertyJson(string $propertyName): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public static function propertyLanguageCode(string $propertyName, string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public static function propertyLazy(string $propertyName, callable $ruleCreator): Chain; public static function propertyLeapDate(string $propertyName, string $format): Chain; @@ -263,7 +249,7 @@ interface PropertyBuilder public static function propertyPesel(string $propertyName): Chain; - public static function propertyPhone(string $propertyName, ?string $countryCode = null): Chain; + public static function propertyPhone(string $propertyName, string|null $countryCode = null): Chain; public static function propertyPhpLabel(string $propertyName): Chain; @@ -299,9 +285,7 @@ interface PropertyBuilder public static function propertyScalarVal(string $propertyName): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public static function propertySize(string $propertyName, string $unit, Rule $rule): Chain; public static function propertySlug(string $propertyName): Chain; @@ -318,9 +302,7 @@ interface PropertyBuilder public static function propertySubdivisionCode(string $propertyName, string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public static function propertySubset(string $propertyName, array $superset): Chain; public static function propertySymbolicLink(string $propertyName): Chain; @@ -339,15 +321,15 @@ interface PropertyBuilder public static function propertyUrl(string $propertyName): Chain; - public static function propertyUuid(string $propertyName, ?int $version = null): Chain; + public static function propertyUuid(string $propertyName, int|null $version = null): Chain; public static function propertyVersion(string $propertyName): Chain; - public static function propertyVideoUrl(string $propertyName, ?string $service = null): Chain; + public static function propertyVideoUrl(string $propertyName, string|null $service = null): Chain; public static function propertyVowel(string $propertyName, string ...$additionalChars): Chain; - public static function propertyWhen(string $propertyName, Rule $when, Rule $then, ?Rule $else = null): Chain; + public static function propertyWhen(string $propertyName, Rule $when, Rule $then, Rule|null $else = null): Chain; public static function propertyWritable(string $propertyName): Chain; diff --git a/library/Mixins/PropertyChain.php b/library/Mixins/PropertyChain.php index 4b0780e7..555c576a 100644 --- a/library/Mixins/PropertyChain.php +++ b/library/Mixins/PropertyChain.php @@ -66,42 +66,34 @@ interface PropertyChain public function propertyContains(string $propertyName, mixed $containsValue, bool $identical = false): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public function propertyContainsAny(string $propertyName, array $needles, bool $identical = false): Chain; public function propertyControl(string $propertyName, string ...$additionalChars): Chain; public function propertyCountable(string $propertyName): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public function propertyCountryCode(string $propertyName, string $set = 'alpha-2'): Chain; public function propertyCpf(string $propertyName): Chain; public function propertyCreditCard(string $propertyName, string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public function propertyCurrencyCode(string $propertyName, string $set = 'alpha-3'): Chain; public function propertyDate(string $propertyName, string $format = 'Y-m-d'): Chain; - public function propertyDateTime(string $propertyName, ?string $format = null): Chain; + public function propertyDateTime(string $propertyName, string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public function propertyDateTimeDiff( string $propertyName, string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public function propertyDecimal(string $propertyName, int $decimals): Chain; @@ -166,16 +158,14 @@ interface PropertyChain public function propertyInfinite(string $propertyName): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public function propertyInstance(string $propertyName, string $class): Chain; public function propertyIntType(string $propertyName): Chain; public function propertyIntVal(string $propertyName): Chain; - public function propertyIp(string $propertyName, string $range = '*', ?int $options = null): Chain; + public function propertyIp(string $propertyName, string $range = '*', int|null $options = null): Chain; public function propertyIsbn(string $propertyName): Chain; @@ -185,14 +175,10 @@ interface PropertyChain public function propertyJson(string $propertyName): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public function propertyLanguageCode(string $propertyName, string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public function propertyLazy(string $propertyName, callable $ruleCreator): Chain; public function propertyLeapDate(string $propertyName, string $format): Chain; @@ -259,7 +245,7 @@ interface PropertyChain public function propertyPesel(string $propertyName): Chain; - public function propertyPhone(string $propertyName, ?string $countryCode = null): Chain; + public function propertyPhone(string $propertyName, string|null $countryCode = null): Chain; public function propertyPhpLabel(string $propertyName): Chain; @@ -291,9 +277,7 @@ interface PropertyChain public function propertyScalarVal(string $propertyName): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public function propertySize(string $propertyName, string $unit, Rule $rule): Chain; public function propertySlug(string $propertyName): Chain; @@ -310,9 +294,7 @@ interface PropertyChain public function propertySubdivisionCode(string $propertyName, string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public function propertySubset(string $propertyName, array $superset): Chain; public function propertySymbolicLink(string $propertyName): Chain; @@ -331,15 +313,15 @@ interface PropertyChain public function propertyUrl(string $propertyName): Chain; - public function propertyUuid(string $propertyName, ?int $version = null): Chain; + public function propertyUuid(string $propertyName, int|null $version = null): Chain; public function propertyVersion(string $propertyName): Chain; - public function propertyVideoUrl(string $propertyName, ?string $service = null): Chain; + public function propertyVideoUrl(string $propertyName, string|null $service = null): Chain; public function propertyVowel(string $propertyName, string ...$additionalChars): Chain; - public function propertyWhen(string $propertyName, Rule $when, Rule $then, ?Rule $else = null): Chain; + public function propertyWhen(string $propertyName, Rule $when, Rule $then, Rule|null $else = null): Chain; public function propertyWritable(string $propertyName): Chain; diff --git a/library/Mixins/UndefOrBuilder.php b/library/Mixins/UndefOrBuilder.php index 0c1be582..ba3e1ca4 100644 --- a/library/Mixins/UndefOrBuilder.php +++ b/library/Mixins/UndefOrBuilder.php @@ -65,41 +65,33 @@ interface UndefOrBuilder public static function undefOrContains(mixed $containsValue, bool $identical = false): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public static function undefOrContainsAny(array $needles, bool $identical = false): Chain; public static function undefOrControl(string ...$additionalChars): Chain; public static function undefOrCountable(): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public static function undefOrCountryCode(string $set = 'alpha-2'): Chain; public static function undefOrCpf(): Chain; public static function undefOrCreditCard(string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public static function undefOrCurrencyCode(string $set = 'alpha-3'): Chain; public static function undefOrDate(string $format = 'Y-m-d'): Chain; - public static function undefOrDateTime(?string $format = null): Chain; + public static function undefOrDateTime(string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public static function undefOrDateTimeDiff( string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public static function undefOrDecimal(int $decimals): Chain; @@ -166,16 +158,14 @@ interface UndefOrBuilder public static function undefOrInfinite(): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public static function undefOrInstance(string $class): Chain; public static function undefOrIntType(): Chain; public static function undefOrIntVal(): Chain; - public static function undefOrIp(string $range = '*', ?int $options = null): Chain; + public static function undefOrIp(string $range = '*', int|null $options = null): Chain; public static function undefOrIsbn(): Chain; @@ -193,14 +183,10 @@ interface UndefOrBuilder public static function undefOrKeySet(Rule $rule, Rule ...$rules): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public static function undefOrLanguageCode(string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public static function undefOrLazy(callable $ruleCreator): Chain; public static function undefOrLeapDate(string $format): Chain; @@ -265,7 +251,7 @@ interface UndefOrBuilder public static function undefOrPesel(): Chain; - public static function undefOrPhone(?string $countryCode = null): Chain; + public static function undefOrPhone(string|null $countryCode = null): Chain; public static function undefOrPhpLabel(): Chain; @@ -303,9 +289,7 @@ interface UndefOrBuilder public static function undefOrScalarVal(): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public static function undefOrSize(string $unit, Rule $rule): Chain; public static function undefOrSlug(): Chain; @@ -322,9 +306,7 @@ interface UndefOrBuilder public static function undefOrSubdivisionCode(string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public static function undefOrSubset(array $superset): Chain; public static function undefOrSymbolicLink(): Chain; @@ -343,15 +325,15 @@ interface UndefOrBuilder public static function undefOrUrl(): Chain; - public static function undefOrUuid(?int $version = null): Chain; + public static function undefOrUuid(int|null $version = null): Chain; public static function undefOrVersion(): Chain; - public static function undefOrVideoUrl(?string $service = null): Chain; + public static function undefOrVideoUrl(string|null $service = null): Chain; public static function undefOrVowel(string ...$additionalChars): Chain; - public static function undefOrWhen(Rule $when, Rule $then, ?Rule $else = null): Chain; + public static function undefOrWhen(Rule $when, Rule $then, Rule|null $else = null): Chain; public static function undefOrWritable(): Chain; diff --git a/library/Mixins/UndefOrChain.php b/library/Mixins/UndefOrChain.php index def676fd..56c4a133 100644 --- a/library/Mixins/UndefOrChain.php +++ b/library/Mixins/UndefOrChain.php @@ -65,41 +65,33 @@ interface UndefOrChain public function undefOrContains(mixed $containsValue, bool $identical = false): Chain; - /** - * @param non-empty-array $needles - */ + /** @param non-empty-array $needles */ public function undefOrContainsAny(array $needles, bool $identical = false): Chain; public function undefOrControl(string ...$additionalChars): Chain; public function undefOrCountable(): Chain; - /** - * @param "alpha-2"|"alpha-3"|"numeric" $set - */ + /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public function undefOrCountryCode(string $set = 'alpha-2'): Chain; public function undefOrCpf(): Chain; public function undefOrCreditCard(string $brand = 'Any'): Chain; - /** - * @param "alpha-3"|"numeric" $set - */ + /** @param "alpha-3"|"numeric" $set */ public function undefOrCurrencyCode(string $set = 'alpha-3'): Chain; public function undefOrDate(string $format = 'Y-m-d'): Chain; - public function undefOrDateTime(?string $format = null): Chain; + public function undefOrDateTime(string|null $format = null): Chain; - /** - * @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type - */ + /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public function undefOrDateTimeDiff( string $type, Rule $rule, - ?string $format = null, - ?DateTimeImmutable $now = null, + string|null $format = null, + DateTimeImmutable|null $now = null, ): Chain; public function undefOrDecimal(int $decimals): Chain; @@ -166,16 +158,14 @@ interface UndefOrChain public function undefOrInfinite(): Chain; - /** - * @param class-string $class - */ + /** @param class-string $class */ public function undefOrInstance(string $class): Chain; public function undefOrIntType(): Chain; public function undefOrIntVal(): Chain; - public function undefOrIp(string $range = '*', ?int $options = null): Chain; + public function undefOrIp(string $range = '*', int|null $options = null): Chain; public function undefOrIsbn(): Chain; @@ -193,14 +183,10 @@ interface UndefOrChain public function undefOrKeySet(Rule $rule, Rule ...$rules): Chain; - /** - * @param "alpha-2"|"alpha-3" $set - */ + /** @param "alpha-2"|"alpha-3" $set */ public function undefOrLanguageCode(string $set = 'alpha-2'): Chain; - /** - * @param callable(mixed): Rule $ruleCreator - */ + /** @param callable(mixed): Rule $ruleCreator */ public function undefOrLazy(callable $ruleCreator): Chain; public function undefOrLeapDate(string $format): Chain; @@ -265,7 +251,7 @@ interface UndefOrChain public function undefOrPesel(): Chain; - public function undefOrPhone(?string $countryCode = null): Chain; + public function undefOrPhone(string|null $countryCode = null): Chain; public function undefOrPhpLabel(): Chain; @@ -303,9 +289,7 @@ interface UndefOrChain public function undefOrScalarVal(): Chain; - /** - * @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit - */ + /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public function undefOrSize(string $unit, Rule $rule): Chain; public function undefOrSlug(): Chain; @@ -322,9 +306,7 @@ interface UndefOrChain public function undefOrSubdivisionCode(string $countryCode): Chain; - /** - * @param mixed[] $superset - */ + /** @param mixed[] $superset */ public function undefOrSubset(array $superset): Chain; public function undefOrSymbolicLink(): Chain; @@ -343,15 +325,15 @@ interface UndefOrChain public function undefOrUrl(): Chain; - public function undefOrUuid(?int $version = null): Chain; + public function undefOrUuid(int|null $version = null): Chain; public function undefOrVersion(): Chain; - public function undefOrVideoUrl(?string $service = null): Chain; + public function undefOrVideoUrl(string|null $service = null): Chain; public function undefOrVowel(string ...$additionalChars): Chain; - public function undefOrWhen(Rule $when, Rule $then, ?Rule $else = null): Chain; + public function undefOrWhen(Rule $when, Rule $then, Rule|null $else = null): Chain; public function undefOrWritable(): Chain; diff --git a/library/Rule.php b/library/Rule.php index 6aa3887c..6ca74eb9 100644 --- a/library/Rule.php +++ b/library/Rule.php @@ -11,7 +11,7 @@ namespace Respect\Validation; interface Rule { - public const TEMPLATE_STANDARD = '__standard__'; + public const string TEMPLATE_STANDARD = '__standard__'; public function evaluate(mixed $input): Result; } diff --git a/library/Rules/AllOf.php b/library/Rules/AllOf.php index 2c4b72a8..06642ba7 100644 --- a/library/Rules/AllOf.php +++ b/library/Rules/AllOf.php @@ -33,14 +33,14 @@ use function count; )] final class AllOf extends Composite { - public const TEMPLATE_ALL = '__all__'; - public const TEMPLATE_SOME = '__some__'; + public const string TEMPLATE_ALL = '__all__'; + public const string TEMPLATE_SOME = '__some__'; public function evaluate(mixed $input): Result { - $children = array_map(static fn (Rule $rule) => $rule->evaluate($input), $this->rules); - $valid = array_reduce($children, static fn (bool $carry, Result $result) => $carry && $result->hasPassed, true); - $failed = array_filter($children, static fn (Result $result): bool => !$result->hasPassed); + $children = array_map(static fn(Rule $rule) => $rule->evaluate($input), $this->rules); + $valid = array_reduce($children, static fn(bool $carry, Result $result) => $carry && $result->hasPassed, true); + $failed = array_filter($children, static fn(Result $result): bool => !$result->hasPassed); $template = self::TEMPLATE_SOME; if (count($children) === count($failed)) { $template = self::TEMPLATE_ALL; diff --git a/library/Rules/AlwaysInvalid.php b/library/Rules/AlwaysInvalid.php index 14ddba69..accdfa52 100644 --- a/library/Rules/AlwaysInvalid.php +++ b/library/Rules/AlwaysInvalid.php @@ -26,7 +26,7 @@ use Respect\Validation\Rules\Core\Simple; )] final class AlwaysInvalid extends Simple { - public const TEMPLATE_SIMPLE = '__simple__'; + public const string TEMPLATE_SIMPLE = '__simple__'; public function isValid(mixed $input): bool { diff --git a/library/Rules/AnyOf.php b/library/Rules/AnyOf.php index d09d1549..8d90f524 100644 --- a/library/Rules/AnyOf.php +++ b/library/Rules/AnyOf.php @@ -27,10 +27,10 @@ final class AnyOf extends Composite { public function evaluate(mixed $input): Result { - $children = array_map(static fn (Rule $rule) => $rule->evaluate($input), $this->rules); + $children = array_map(static fn(Rule $rule) => $rule->evaluate($input), $this->rules); $valid = array_reduce( $children, - static fn (bool $carry, Result $result) => $carry || $result->hasPassed, + static fn(bool $carry, Result $result) => $carry || $result->hasPassed, false, ); diff --git a/library/Rules/Attributes.php b/library/Rules/Attributes.php index 877e14a9..690fcaeb 100644 --- a/library/Rules/Attributes.php +++ b/library/Rules/Attributes.php @@ -31,6 +31,7 @@ final class Attributes implements Rule foreach ($reflection->getAttributes(Rule::class, ReflectionAttribute::IS_INSTANCEOF) as $attribute) { $rules[] = $attribute->newInstance(); } + foreach ($reflection->getProperties() as $property) { $childrenRules = []; foreach ($property->getAttributes(Rule::class, ReflectionAttribute::IS_INSTANCEOF) as $attribute) { diff --git a/library/Rules/Base.php b/library/Rules/Base.php index 0955bd62..7218d690 100644 --- a/library/Rules/Base.php +++ b/library/Rules/Base.php @@ -28,7 +28,7 @@ final readonly class Base implements Rule { public function __construct( private int $base, - private string $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + private string $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ) { $max = mb_strlen($this->chars); if ($base > $max) { @@ -42,7 +42,7 @@ final readonly class Base implements Rule (bool) preg_match('@^[' . mb_substr($this->chars, 0, $this->base) . ']+$@', (string) $input), $input, $this, - ['base' => $this->base] + ['base' => $this->base], ); } } diff --git a/library/Rules/Between.php b/library/Rules/Between.php index 9473ef98..f788570d 100644 --- a/library/Rules/Between.php +++ b/library/Rules/Between.php @@ -33,12 +33,12 @@ final class Between extends Envelope parent::__construct( new AllOf( new GreaterThanOrEqual($minValue), - new LessThanOrEqual($maxValue) + new LessThanOrEqual($maxValue), ), [ 'minValue' => $minValue, 'maxValue' => $maxValue, - ] + ], ); } } diff --git a/library/Rules/BetweenExclusive.php b/library/Rules/BetweenExclusive.php index e0efdd84..a4750d92 100644 --- a/library/Rules/BetweenExclusive.php +++ b/library/Rules/BetweenExclusive.php @@ -32,7 +32,7 @@ final class BetweenExclusive extends Envelope parent::__construct( new AllOf(new GreaterThan($minimum), new LessThan($maximum)), - ['minValue' => $minimum, 'maxValue' => $maximum] + ['minValue' => $minimum, 'maxValue' => $maximum], ); } } diff --git a/library/Rules/Bsn.php b/library/Rules/Bsn.php index cc5d1d9d..bfe0c1be 100644 --- a/library/Rules/Bsn.php +++ b/library/Rules/Bsn.php @@ -19,9 +19,7 @@ use function is_scalar; use function mb_strlen; use function strval; -/** - * @see https://nl.wikipedia.org/wiki/Burgerservicenummer - */ +/** @see https://nl.wikipedia.org/wiki/Burgerservicenummer */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] #[Template( '{{name}} must be a valid BSN', diff --git a/library/Rules/Call.php b/library/Rules/Call.php index 53ca9773..f94df868 100644 --- a/library/Rules/Call.php +++ b/library/Rules/Call.php @@ -27,21 +27,19 @@ use function set_error_handler; )] final class Call implements Rule { - /** - * @var callable - */ + /** @var callable */ private $callable; public function __construct( callable $callable, - private readonly Rule $rule + private readonly Rule $rule, ) { $this->callable = $callable; } public function evaluate(mixed $input): Result { - set_error_handler(static function (int $severity, string $message, ?string $filename, int $line): void { + set_error_handler(static function (int $severity, string $message, string|null $filename, int $line): void { throw new ErrorException($message, 0, $severity, $filename, $line); }); diff --git a/library/Rules/Callback.php b/library/Rules/Callback.php index 2847f81d..6836c9f2 100644 --- a/library/Rules/Callback.php +++ b/library/Rules/Callback.php @@ -24,14 +24,10 @@ use function count; )] final class Callback extends Simple { - /** - * @var callable - */ + /** @var callable */ private $callback; - /** - * @var mixed[] - */ + /** @var mixed[] */ private readonly array $arguments; public function __construct(callable $callback, mixed ...$arguments) @@ -45,9 +41,7 @@ final class Callback extends Simple return (bool) call_user_func_array($this->callback, $this->getArguments($input)); } - /** - * @return mixed[] - */ + /** @return mixed[] */ private function getArguments(mixed $input): array { $arguments = [$input]; diff --git a/library/Rules/Cnpj.php b/library/Rules/Cnpj.php index be4b2e33..c8f9cccb 100644 --- a/library/Rules/Cnpj.php +++ b/library/Rules/Cnpj.php @@ -64,16 +64,14 @@ final class Cnpj extends Simple return $digits[13] == $check; } - /** - * @return int[] - */ + /** @return int[] */ private function getDigits(string $input): array { return array_map( 'intval', str_split( - (string) preg_replace('/\D/', '', $input) - ) + (string) preg_replace('/\D/', '', $input), + ), ); } } diff --git a/library/Rules/Contains.php b/library/Rules/Contains.php index d03350a4..cde8f320 100644 --- a/library/Rules/Contains.php +++ b/library/Rules/Contains.php @@ -29,7 +29,7 @@ final readonly class Contains implements Rule { public function __construct( private mixed $containsValue, - private bool $identical = false + private bool $identical = false, ) { } diff --git a/library/Rules/ContainsAny.php b/library/Rules/ContainsAny.php index 6681d1b2..0d0eac4d 100644 --- a/library/Rules/ContainsAny.php +++ b/library/Rules/ContainsAny.php @@ -32,9 +32,10 @@ final class ContainsAny extends Envelope } $rules = $this->getRules($needles, $identical); + parent::__construct( count($rules) === 1 ? $rules[0] : new AnyOf(...$rules), - ['needles' => $needles] + ['needles' => $needles], ); } @@ -49,7 +50,7 @@ final class ContainsAny extends Envelope static function ($needle) use ($identical): Contains { return new Contains($needle, $identical); }, - $needles + $needles, ); } } diff --git a/library/Rules/Core/Comparison.php b/library/Rules/Core/Comparison.php index aad51dae..ade8739d 100644 --- a/library/Rules/Core/Comparison.php +++ b/library/Rules/Core/Comparison.php @@ -17,10 +17,8 @@ abstract class Comparison implements Rule { use CanCompareValues; - abstract protected function compare(mixed $left, mixed $right): bool; - public function __construct( - private readonly mixed $compareTo + private readonly mixed $compareTo, ) { } @@ -37,4 +35,6 @@ abstract class Comparison implements Rule return new Result($this->compare($left, $right), $input, $this, $parameters); } + + abstract protected function compare(mixed $left, mixed $right): bool; } diff --git a/library/Rules/Core/Envelope.php b/library/Rules/Core/Envelope.php index aac4371a..8acd2d34 100644 --- a/library/Rules/Core/Envelope.php +++ b/library/Rules/Core/Envelope.php @@ -17,7 +17,7 @@ abstract class Envelope implements Rule /** @param array $parameters */ public function __construct( private readonly Rule $rule, - private readonly array $parameters = [] + private readonly array $parameters = [], ) { } diff --git a/library/Rules/Core/FilteredNonEmptyArray.php b/library/Rules/Core/FilteredNonEmptyArray.php index 735e2742..523569a6 100644 --- a/library/Rules/Core/FilteredNonEmptyArray.php +++ b/library/Rules/Core/FilteredNonEmptyArray.php @@ -18,9 +18,6 @@ use function iterator_to_array; abstract class FilteredNonEmptyArray extends Wrapper { - /** @param non-empty-array $input */ - abstract protected function evaluateNonEmptyArray(array $input): Result; - public function evaluate(mixed $input): Result { $iterableResult = (new IterableType())->evaluate($input); @@ -38,8 +35,12 @@ abstract class FilteredNonEmptyArray extends Wrapper return $this->evaluateNonEmptyArray($array); } + /** @param non-empty-array $input */ + abstract protected function evaluateNonEmptyArray(array $input): Result; + /** * @param iterable $input + * * @return array */ private function toArray(iterable $input): array diff --git a/library/Rules/Core/FilteredString.php b/library/Rules/Core/FilteredString.php index 6b6f8d62..9a62128a 100644 --- a/library/Rules/Core/FilteredString.php +++ b/library/Rules/Core/FilteredString.php @@ -19,12 +19,10 @@ use function str_split; abstract class FilteredString implements Rule { - public const TEMPLATE_EXTRA = '__extra__'; + public const string TEMPLATE_EXTRA = '__extra__'; private readonly string $additionalChars; - abstract protected function isValid(string $input): bool; - public function __construct(string ...$additionalChars) { $this->additionalChars = implode($additionalChars); @@ -49,6 +47,8 @@ abstract class FilteredString implements Rule return new Result($isValid, $input, $this, $parameters, $template); } + abstract protected function isValid(string $input): bool; + private function filter(string $input): string { return str_replace(str_split($this->additionalChars), '', $input); diff --git a/library/Rules/Core/Nameable.php b/library/Rules/Core/Nameable.php index a751c8e3..43828efa 100644 --- a/library/Rules/Core/Nameable.php +++ b/library/Rules/Core/Nameable.php @@ -11,5 +11,5 @@ namespace Respect\Validation\Rules\Core; interface Nameable { - public function getName(): ?string; + public function getName(): string|null; } diff --git a/library/Rules/Core/Reducer.php b/library/Rules/Core/Reducer.php index 9889bc11..da7c70d0 100644 --- a/library/Rules/Core/Reducer.php +++ b/library/Rules/Core/Reducer.php @@ -21,7 +21,7 @@ final class Reducer extends Wrapper parent::__construct($rules === [] ? $rule1 : new AllOf($rule1, ...$rules)); } - public function withTemplate(?string $template): self + public function withTemplate(string|null $template): self { if ($template === null) { return $this; @@ -30,7 +30,7 @@ final class Reducer extends Wrapper return new self(new Templated($this->rule, $template)); } - public function withName(?string $name): self + public function withName(string|null $name): self { if ($name === null) { return $this; @@ -39,7 +39,7 @@ final class Reducer extends Wrapper return new self(new Named($this->rule, $name)); } - public function getName(): ?string + public function getName(): string|null { if ($this->rule instanceof Nameable) { return $this->rule->getName(); diff --git a/library/Rules/Core/Wrapper.php b/library/Rules/Core/Wrapper.php index 45880d70..8816abc7 100644 --- a/library/Rules/Core/Wrapper.php +++ b/library/Rules/Core/Wrapper.php @@ -15,7 +15,7 @@ use Respect\Validation\Rule; abstract class Wrapper implements Rule { public function __construct( - protected readonly Rule $rule + protected readonly Rule $rule, ) { } diff --git a/library/Rules/CountryCode.php b/library/Rules/CountryCode.php index 6c795fee..75af1e1e 100644 --- a/library/Rules/CountryCode.php +++ b/library/Rules/CountryCode.php @@ -33,13 +33,13 @@ final readonly class CountryCode implements Rule /** @param "alpha-2"|"alpha-3"|"numeric" $set */ public function __construct( private string $set = 'alpha-2', - ?Countries $countries = null + Countries|null $countries = null, ) { if (!class_exists(Countries::class)) { throw new MissingComposerDependencyException( 'SubdivisionCode rule requires PHP ISO Codes', 'sokil/php-isocodes', - 'sokil/php-isocodes-db-only' + 'sokil/php-isocodes-db-only', ); } @@ -48,7 +48,7 @@ final readonly class CountryCode implements Rule throw new InvalidRuleConstructorException( '"%s" is not a valid set for ISO 3166-1 (Available: %s)', $set, - $availableOptions + $availableOptions, ); } diff --git a/library/Rules/CreditCard.php b/library/Rules/CreditCard.php index e379b4df..4ab5bda3 100644 --- a/library/Rules/CreditCard.php +++ b/library/Rules/CreditCard.php @@ -33,17 +33,17 @@ use function preg_replace; )] final readonly class CreditCard implements Rule { - public const TEMPLATE_BRANDED = '__branded__'; - public const ANY = 'Any'; - public const AMERICAN_EXPRESS = 'American Express'; - public const DINERS_CLUB = 'Diners Club'; - public const DISCOVER = 'Discover'; - public const JCB = 'JCB'; - public const MASTERCARD = 'MasterCard'; - public const VISA = 'Visa'; - public const RUPAY = 'RuPay'; + public const string TEMPLATE_BRANDED = '__branded__'; + public const string ANY = 'Any'; + public const string AMERICAN_EXPRESS = 'American Express'; + public const string DINERS_CLUB = 'Diners Club'; + public const string DISCOVER = 'Discover'; + public const string JCB = 'JCB'; + public const string MASTERCARD = 'MasterCard'; + public const string VISA = 'Visa'; + public const string RUPAY = 'RuPay'; - private const BRAND_REGEX_LIST = [ + private const array BRAND_REGEX_LIST = [ self::ANY => '/^[0-9]+$/', self::AMERICAN_EXPRESS => '/^3[47]\d{13}$/', self::DINERS_CLUB => '/^3(?:0[0-5]|[68]\d)\d{11}$/', @@ -55,13 +55,13 @@ final readonly class CreditCard implements Rule ]; public function __construct( - private string $brand = self::ANY + private string $brand = self::ANY, ) { if (!isset(self::BRAND_REGEX_LIST[$brand])) { throw new InvalidRuleConstructorException( '"%s" is not a valid credit card brand (Available: %s)', $brand, - array_keys(self::BRAND_REGEX_LIST) + array_keys(self::BRAND_REGEX_LIST), ); } } @@ -84,7 +84,7 @@ final readonly class CreditCard implements Rule $input, $this, $parameters, - $template + $template, ); } } diff --git a/library/Rules/CurrencyCode.php b/library/Rules/CurrencyCode.php index 9b04a0cc..143ca370 100644 --- a/library/Rules/CurrencyCode.php +++ b/library/Rules/CurrencyCode.php @@ -32,13 +32,13 @@ final readonly class CurrencyCode implements Rule /** @param "alpha-3"|"numeric" $set */ public function __construct( private string $set = 'alpha-3', - ?Currencies $currencies = null + Currencies|null $currencies = null, ) { if (!class_exists(Currencies::class)) { throw new MissingComposerDependencyException( 'CurrencyCode rule requires PHP ISO Codes', 'sokil/php-isocodes', - 'sokil/php-isocodes-db-only' + 'sokil/php-isocodes-db-only', ); } @@ -47,9 +47,10 @@ final readonly class CurrencyCode implements Rule throw new InvalidRuleConstructorException( '"%s" is not a valid set for ISO 4217 (Available: %s)', $set, - $availableSets + $availableSets, ); } + $this->currencies = $currencies ?? new Currencies(); } diff --git a/library/Rules/Date.php b/library/Rules/Date.php index 5718dcc7..9e88109e 100644 --- a/library/Rules/Date.php +++ b/library/Rules/Date.php @@ -31,7 +31,7 @@ final readonly class Date implements Rule use CanValidateDateTime; public function __construct( - private string $format = 'Y-m-d' + private string $format = 'Y-m-d', ) { if (!preg_match('/^[djSFmMnYy\W]+$/', $format)) { throw new InvalidRuleConstructorException('"%s" is not a valid date format', $format); diff --git a/library/Rules/DateTime.php b/library/Rules/DateTime.php index 2fcbd402..cdfb7e93 100644 --- a/library/Rules/DateTime.php +++ b/library/Rules/DateTime.php @@ -35,10 +35,10 @@ final class DateTime implements Rule { use CanValidateDateTime; - public const TEMPLATE_FORMAT = '__format__'; + public const string TEMPLATE_FORMAT = '__format__'; public function __construct( - private readonly ?string $format = null + private readonly string|null $format = null, ) { } diff --git a/library/Rules/DateTimeDiff.php b/library/Rules/DateTimeDiff.php index 6696c6ec..adfc5c3f 100644 --- a/library/Rules/DateTimeDiff.php +++ b/library/Rules/DateTimeDiff.php @@ -26,44 +26,44 @@ use function ucfirst; #[Template( 'The number of {{type|trans}} between now and', 'The number of {{type|trans}} between now and', - self::TEMPLATE_STANDARD + self::TEMPLATE_STANDARD, )] #[Template( 'The number of {{type|trans}} between {{now}} and', 'The number of {{type|trans}} between {{now}} and', - self::TEMPLATE_CUSTOMIZED + self::TEMPLATE_CUSTOMIZED, )] #[Template( 'For comparison with {{now|raw}}, {{name}} must be a valid datetime', 'For comparison with {{now|raw}}, {{name}} must not be a valid datetime', - self::TEMPLATE_NOT_A_DATE + self::TEMPLATE_NOT_A_DATE, )] #[Template( 'For comparison with {{now|raw}}, {{name}} must be a valid datetime in the format {{sample|raw}}', 'For comparison with {{now|raw}}, {{name}} must not be a valid datetime in the format {{sample|raw}}', - self::TEMPLATE_WRONG_FORMAT + self::TEMPLATE_WRONG_FORMAT, )] final readonly class DateTimeDiff implements Rule { use CanValidateDateTime; - public const TEMPLATE_CUSTOMIZED = '__customized__'; - public const TEMPLATE_NOT_A_DATE = '__not_a_date__'; - public const TEMPLATE_WRONG_FORMAT = '__wrong_format__'; + public const string TEMPLATE_CUSTOMIZED = '__customized__'; + public const string TEMPLATE_NOT_A_DATE = '__not_a_date__'; + public const string TEMPLATE_WRONG_FORMAT = '__wrong_format__'; /** @param "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" $type */ public function __construct( private string $type, private Rule $rule, - private ?string $format = null, - private ?DateTimeImmutable $now = null, + private string|null $format = null, + private DateTimeImmutable|null $now = null, ) { $availableTypes = ['years', 'months', 'days', 'hours', 'minutes', 'seconds', 'microseconds']; if (!in_array($this->type, $availableTypes, true)) { throw new InvalidRuleConstructorException( '"%s" is not a valid type of age (Available: %s)', $this->type, - $availableTypes + $availableTypes, ); } } @@ -88,7 +88,7 @@ final readonly class DateTimeDiff implements Rule $this, $this->rule->evaluate($this->comparisonValue($now, $compareTo)), ['type' => $this->type, 'now' => $nowPlaceholder], - $nowPlaceholder === 'now' ? self::TEMPLATE_STANDARD : self::TEMPLATE_CUSTOMIZED + $nowPlaceholder === 'now' ? self::TEMPLATE_STANDARD : self::TEMPLATE_CUSTOMIZED, ); } @@ -118,7 +118,7 @@ final readonly class DateTimeDiff implements Rule return $now->format($this->format); } - private function createDateTimeObject(mixed $input): ?DateTimeInterface + private function createDateTimeObject(mixed $input): DateTimeInterface|null { if ($input instanceof DateTimeInterface) { return $input; diff --git a/library/Rules/Decimal.php b/library/Rules/Decimal.php index d1d2b6f0..dc934a0e 100644 --- a/library/Rules/Decimal.php +++ b/library/Rules/Decimal.php @@ -28,7 +28,7 @@ use function var_export; final readonly class Decimal implements Rule { public function __construct( - private int $decimals + private int $decimals, ) { } diff --git a/library/Rules/Domain.php b/library/Rules/Domain.php index c64d4886..65ba42ca 100644 --- a/library/Rules/Domain.php +++ b/library/Rules/Domain.php @@ -63,7 +63,7 @@ final class Domain implements Rule new StringType(), new NoWhitespace(), new Contains('.'), - new Length(new GreaterThanOrEqual(3)) + new Length(new GreaterThanOrEqual(3)), ); } @@ -86,10 +86,10 @@ final class Domain implements Rule new Not(new Contains('--')), new Callback(static function ($str) { return mb_substr_count($str, '--') == 1; - }) + }), ), - new Not(new EndsWith('-')) - ) + new Not(new EndsWith('-')), + ), ); } } diff --git a/library/Rules/Each.php b/library/Rules/Each.php index 807558db..cb8ed2c5 100644 --- a/library/Rules/Each.php +++ b/library/Rules/Each.php @@ -30,9 +30,10 @@ final class Each extends FilteredNonEmptyArray foreach ($input as $key => $value) { $children[] = $this->rule->evaluate($value)->withPath($key); } + $hasPassed = array_reduce( $children, - static fn ($carry, $childResult) => $carry && $childResult->hasPassed, + static fn($carry, $childResult) => $carry && $childResult->hasPassed, true, ); diff --git a/library/Rules/Email.php b/library/Rules/Email.php index e8971bd0..218ad3ee 100644 --- a/library/Rules/Email.php +++ b/library/Rules/Email.php @@ -29,13 +29,14 @@ use const FILTER_VALIDATE_EMAIL; )] final class Email extends Simple { - private readonly ?EmailValidator $validator; + private readonly EmailValidator|null $validator; - public function __construct(?EmailValidator $validator = null) + public function __construct(EmailValidator|null $validator = null) { if ($validator === null && func_num_args() === 0 && class_exists(EmailValidator::class)) { $validator = new EmailValidator(); } + $this->validator = $validator; } diff --git a/library/Rules/EndsWith.php b/library/Rules/EndsWith.php index 68273d6d..d98cf430 100644 --- a/library/Rules/EndsWith.php +++ b/library/Rules/EndsWith.php @@ -29,7 +29,7 @@ final readonly class EndsWith implements Rule { public function __construct( private mixed $endValue, - private bool $identical = false + private bool $identical = false, ) { } diff --git a/library/Rules/Equals.php b/library/Rules/Equals.php index 08fc476a..7b5ef8fd 100644 --- a/library/Rules/Equals.php +++ b/library/Rules/Equals.php @@ -24,7 +24,7 @@ use function is_scalar; final readonly class Equals implements Rule { public function __construct( - private mixed $compareTo + private mixed $compareTo, ) { } diff --git a/library/Rules/Extension.php b/library/Rules/Extension.php index dbb5ae99..b1abab3c 100644 --- a/library/Rules/Extension.php +++ b/library/Rules/Extension.php @@ -28,7 +28,7 @@ use const PATHINFO_EXTENSION; final readonly class Extension implements Rule { public function __construct( - private string $extension + private string $extension, ) { } diff --git a/library/Rules/Factor.php b/library/Rules/Factor.php index 0c9bb2f2..4c35b777 100644 --- a/library/Rules/Factor.php +++ b/library/Rules/Factor.php @@ -15,7 +15,7 @@ use Respect\Validation\Result; use Respect\Validation\Rule; use function abs; -use function is_integer; +use function is_int; use function is_numeric; use function preg_match; @@ -27,7 +27,7 @@ use function preg_match; final readonly class Factor implements Rule { public function __construct( - private int $dividend + private int $dividend, ) { } @@ -50,6 +50,6 @@ final readonly class Factor implements Rule // The dividend divided by the input must be an integer if input is a // factor of the dividend. - return new Result(is_integer($dividend / $input), $input, $this, $parameters); + return new Result(is_int($dividend / $input), $input, $this, $parameters); } } diff --git a/library/Rules/FilterVar.php b/library/Rules/FilterVar.php index b035917f..e8cc0a90 100644 --- a/library/Rules/FilterVar.php +++ b/library/Rules/FilterVar.php @@ -35,7 +35,7 @@ use const FILTER_VALIDATE_URL; )] final class FilterVar extends Envelope { - private const ALLOWED_FILTERS = [ + private const array ALLOWED_FILTERS = [ FILTER_VALIDATE_BOOLEAN => 'is_bool', FILTER_VALIDATE_DOMAIN => 'is_string', FILTER_VALIDATE_EMAIL => 'is_string', @@ -59,7 +59,7 @@ final class FilterVar extends Envelope parent::__construct(new Callback(static function ($input) use ($filter, $arguments) { return (self::ALLOWED_FILTERS[$filter])( - filter_var($input, ...$arguments) + filter_var($input, ...$arguments), ); })); } diff --git a/library/Rules/Hetu.php b/library/Rules/Hetu.php index c7452a5d..1d9ade04 100644 --- a/library/Rules/Hetu.php +++ b/library/Rules/Hetu.php @@ -18,9 +18,7 @@ use function is_string; use function preg_match; use function str_split; -/** - * @see https://en.wikipedia.org/wiki/National_identification_number#Finland - */ +/** @see https://en.wikipedia.org/wiki/National_identification_number#Finland */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] #[Template( '{{name}} must be a valid Finnish personal identity code', diff --git a/library/Rules/Iban.php b/library/Rules/Iban.php index b515b0ff..455e0553 100644 --- a/library/Rules/Iban.php +++ b/library/Rules/Iban.php @@ -30,7 +30,7 @@ use function substr; )] final class Iban extends Simple { - private const COUNTRIES_LENGTHS = [ + private const array COUNTRIES_LENGTHS = [ 'AL' => 28, 'AD' => 24, 'AT' => 20, @@ -144,7 +144,7 @@ final class Iban extends Simple static function (array $match): string { return strval(ord($match[0]) - 55); }, - $reArrangedIban + $reArrangedIban, ); } } diff --git a/library/Rules/Identical.php b/library/Rules/Identical.php index c5a47b19..c9cbf063 100644 --- a/library/Rules/Identical.php +++ b/library/Rules/Identical.php @@ -22,7 +22,7 @@ use Respect\Validation\Rule; final readonly class Identical implements Rule { public function __construct( - private mixed $compareTo + private mixed $compareTo, ) { } diff --git a/library/Rules/Image.php b/library/Rules/Image.php index 45f8b2e6..4a1c9123 100644 --- a/library/Rules/Image.php +++ b/library/Rules/Image.php @@ -29,7 +29,7 @@ use const FILEINFO_MIME_TYPE; final class Image extends Simple { public function __construct( - private finfo $fileInfo = new finfo(FILEINFO_MIME_TYPE) + private finfo $fileInfo = new finfo(FILEINFO_MIME_TYPE), ) { } diff --git a/library/Rules/Imei.php b/library/Rules/Imei.php index 5e727ce3..d91cbe4c 100644 --- a/library/Rules/Imei.php +++ b/library/Rules/Imei.php @@ -24,7 +24,7 @@ use function preg_replace; )] final class Imei extends Simple { - private const IMEI_SIZE = 15; + private const int IMEI_SIZE = 15; public function isValid(mixed $input): bool { diff --git a/library/Rules/In.php b/library/Rules/In.php index bbfdd895..6727ece1 100644 --- a/library/Rules/In.php +++ b/library/Rules/In.php @@ -28,7 +28,7 @@ final readonly class In implements Rule { public function __construct( private mixed $haystack, - private bool $compareIdentical = false + private bool $compareIdentical = false, ) { } diff --git a/library/Rules/Instance.php b/library/Rules/Instance.php index 8c41b40b..7207c1b9 100644 --- a/library/Rules/Instance.php +++ b/library/Rules/Instance.php @@ -23,7 +23,7 @@ final readonly class Instance implements Rule { /** @param class-string $class */ public function __construct( - private string $class + private string $class, ) { } diff --git a/library/Rules/Ip.php b/library/Rules/Ip.php index a5948b31..7d5c65e7 100644 --- a/library/Rules/Ip.php +++ b/library/Rules/Ip.php @@ -45,17 +45,17 @@ use const PHP_INT_MAX; )] final class Ip implements Rule { - public const TEMPLATE_NETWORK_RANGE = '__network_range__'; + public const string TEMPLATE_NETWORK_RANGE = '__network_range__'; - private ?string $range = null; + private string|null $range = null; - private ?string $startAddress = null; + private string|null $startAddress = null; - private ?string $endAddress = null; + private string|null $endAddress = null; - private ?string $mask = null; + private string|null $mask = null; - public function __construct(string $range = '*', private ?int $options = null) + public function __construct(string $range = '*', private int|null $options = null) { $this->parseRange($range); $this->range = $this->createRange(); @@ -84,7 +84,7 @@ final class Ip implements Rule return Result::passed($input, $this, $parameters, $template); } - private function createRange(): ?string + private function createRange(): string|null { if ($this->startAddress && $this->endAddress) { return $this->startAddress . '-' . $this->endAddress; diff --git a/library/Rules/Isbn.php b/library/Rules/Isbn.php index 6215b893..1f25c882 100644 --- a/library/Rules/Isbn.php +++ b/library/Rules/Isbn.php @@ -25,10 +25,8 @@ use function sprintf; )] final class Isbn extends Simple { - /** - * @see https://howtodoinjava.com/regex/java-regex-validate-international-standard-book-number-isbns - */ - private const PIECES = [ + /** @see https://howtodoinjava.com/regex/java-regex-validate-international-standard-book-number-isbns */ + private const array PIECES = [ '^(?:ISBN(?:-1[03])?:? )?(?=[0-9X]{10}$|(?=(?:[0-9]+[- ]){3})', '[- 0-9X]{13}$|97[89][0-9]{10}$|(?=(?:[0-9]+[- ]){4})[- 0-9]{17}$)', '(?:97[89][- ]?)?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X]$', diff --git a/library/Rules/KeyExists.php b/library/Rules/KeyExists.php index 502c1763..cd17d7ac 100644 --- a/library/Rules/KeyExists.php +++ b/library/Rules/KeyExists.php @@ -27,7 +27,7 @@ use function is_array; final class KeyExists implements Rule, KeyRelated { public function __construct( - private readonly int|string $key + private readonly int|string $key, ) { } diff --git a/library/Rules/KeySet.php b/library/Rules/KeySet.php index 8bb4c7f7..df85d125 100644 --- a/library/Rules/KeySet.php +++ b/library/Rules/KeySet.php @@ -33,25 +33,25 @@ use function array_slice; #[Template( '{{name}} contains both missing and extra keys', '{{name}} contains no missing or extra keys.', - self::TEMPLATE_BOTH + self::TEMPLATE_BOTH, )] #[Template( '{{name}} contains extra keys', '{{name}} contains no extra keys', - self::TEMPLATE_EXTRA_KEYS + self::TEMPLATE_EXTRA_KEYS, )] #[Template( '{{name}} contains missing keys', '{{name}} contains no missing keys', - self::TEMPLATE_MISSING_KEYS + self::TEMPLATE_MISSING_KEYS, )] final readonly class KeySet implements Rule { - public const TEMPLATE_BOTH = '__both__'; - public const TEMPLATE_EXTRA_KEYS = '__extra_keys__'; - public const TEMPLATE_MISSING_KEYS = '__missing_keys__'; + public const string TEMPLATE_BOTH = '__both__'; + public const string TEMPLATE_EXTRA_KEYS = '__extra_keys__'; + public const string TEMPLATE_MISSING_KEYS = '__missing_keys__'; - private const MAX_DIFF_KEYS = 10; + private const int MAX_DIFF_KEYS = 10; /** @var array */ private array $rules; @@ -81,7 +81,7 @@ final readonly class KeySet implements Rule $keys = new Reducer(...array_merge($this->rules, array_map( static fn(string|int $key) => new Not(new KeyExists($key)), - array_slice(array_diff(array_keys($input), $this->allKeys), 0, self::MAX_DIFF_KEYS) + array_slice(array_diff(array_keys($input), $this->allKeys), 0, self::MAX_DIFF_KEYS), ))); $keysResult = $keys->evaluate($input); diff --git a/library/Rules/LanguageCode.php b/library/Rules/LanguageCode.php index 70071d26..ad7824b8 100644 --- a/library/Rules/LanguageCode.php +++ b/library/Rules/LanguageCode.php @@ -34,13 +34,13 @@ final readonly class LanguageCode implements Rule /** @param "alpha-2"|"alpha-3" $set */ public function __construct( private readonly string $set = 'alpha-2', - ?Languages $languages = null + Languages|null $languages = null, ) { if (!class_exists(Countries::class)) { throw new MissingComposerDependencyException( 'LanguageCode rule requires PHP ISO Codes', 'sokil/php-isocodes', - 'sokil/php-isocodes-db-only' + 'sokil/php-isocodes-db-only', ); } @@ -49,7 +49,7 @@ final readonly class LanguageCode implements Rule throw new InvalidRuleConstructorException( '"%s" is not a valid set for ISO 639-3 (Available: %s)', $set, - $availableSets + $availableSets, ); } diff --git a/library/Rules/LeapDate.php b/library/Rules/LeapDate.php index 826f6195..d67a904e 100644 --- a/library/Rules/LeapDate.php +++ b/library/Rules/LeapDate.php @@ -25,7 +25,7 @@ use function is_scalar; final class LeapDate extends Simple { public function __construct( - private readonly string $format + private readonly string $format, ) { } diff --git a/library/Rules/Length.php b/library/Rules/Length.php index cbc43664..99da3bd2 100644 --- a/library/Rules/Length.php +++ b/library/Rules/Length.php @@ -25,16 +25,16 @@ use function ucfirst; #[Template( 'The length of', 'The length of', - self::TEMPLATE_STANDARD + self::TEMPLATE_STANDARD, )] #[Template( '{{name}} must be a countable value or a string', '{{name}} must not be a countable value or a string', - self::TEMPLATE_WRONG_TYPE + self::TEMPLATE_WRONG_TYPE, )] final class Length extends Wrapper { - public const TEMPLATE_WRONG_TYPE = '__wrong_type__'; + public const string TEMPLATE_WRONG_TYPE = '__wrong_type__'; public function evaluate(mixed $input): Result { @@ -47,7 +47,7 @@ final class Length extends Wrapper return Result::fromAdjacent($input, 'length', $this, $this->rule->evaluate($length)); } - private function extractLength(mixed $input): ?int + private function extractLength(mixed $input): int|null { if (is_string($input)) { return (int) mb_strlen($input); diff --git a/library/Rules/Luhn.php b/library/Rules/Luhn.php index 619edb5e..531a747e 100644 --- a/library/Rules/Luhn.php +++ b/library/Rules/Luhn.php @@ -17,9 +17,7 @@ use function array_map; use function count; use function str_split; -/** - * @see https://en.wikipedia.org/wiki/Luhn_algorithm - */ +/** @see https://en.wikipedia.org/wiki/Luhn_algorithm */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] #[Template( '{{name}} must be a valid Luhn number', @@ -42,9 +40,10 @@ final class Luhn extends Simple if ($parity == $i % 2) { $digit <<= 1; if (9 < $digit) { - $digit = $digit - 9; + $digit -= 9; } } + $sum += $digit; } diff --git a/library/Rules/Mimetype.php b/library/Rules/Mimetype.php index 2478665c..78e36bf5 100644 --- a/library/Rules/Mimetype.php +++ b/library/Rules/Mimetype.php @@ -30,7 +30,7 @@ final readonly class Mimetype implements Rule { public function __construct( private string $mimetype, - private finfo $fileInfo = new finfo() + private finfo $fileInfo = new finfo(), ) { } @@ -53,7 +53,7 @@ final readonly class Mimetype implements Rule $this->mimetype === $this->fileInfo->file($input, FILEINFO_MIME_TYPE), $input, $this, - $parameters + $parameters, ); } } diff --git a/library/Rules/Multiple.php b/library/Rules/Multiple.php index cdb61b17..ad2f2d9e 100644 --- a/library/Rules/Multiple.php +++ b/library/Rules/Multiple.php @@ -22,7 +22,7 @@ use Respect\Validation\Rule; final readonly class Multiple implements Rule { public function __construct( - private int $multipleOf + private int $multipleOf, ) { } diff --git a/library/Rules/Named.php b/library/Rules/Named.php index bebb8509..fa75269f 100644 --- a/library/Rules/Named.php +++ b/library/Rules/Named.php @@ -20,7 +20,7 @@ final class Named extends Wrapper implements Nameable { public function __construct( Rule $rule, - private readonly string $name + private readonly string $name, ) { parent::__construct($rule); } diff --git a/library/Rules/NfeAccessKey.php b/library/Rules/NfeAccessKey.php index 125523bd..5dea09a7 100644 --- a/library/Rules/NfeAccessKey.php +++ b/library/Rules/NfeAccessKey.php @@ -18,9 +18,7 @@ use function floor; use function mb_strlen; use function str_split; -/** - * @see (pt-br) Manual de Integração do Contribuinte v4.0.1 em http://www.nfe.fazenda.gov.br - */ +/** @see (pt-br) Manual de Integração do Contribuinte v4.0.1 em http://www.nfe.fazenda.gov.br */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] #[Template( '{{name}} must be a valid NFe access key', diff --git a/library/Rules/Nif.php b/library/Rules/Nif.php index 0720b110..3bd5f732 100644 --- a/library/Rules/Nif.php +++ b/library/Rules/Nif.php @@ -21,9 +21,7 @@ use function mb_substr; use function preg_match; use function str_split; -/** - * @see https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal - */ +/** @see https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] #[Template( '{{name}} must be a valid NIF', diff --git a/library/Rules/Nip.php b/library/Rules/Nip.php index aaf7c85f..88415f0b 100644 --- a/library/Rules/Nip.php +++ b/library/Rules/Nip.php @@ -18,9 +18,7 @@ use function is_scalar; use function preg_match; use function str_split; -/** - * @see https://en.wikipedia.org/wiki/VAT_identification_number - */ +/** @see https://en.wikipedia.org/wiki/VAT_identification_number */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] #[Template( '{{name}} must be a valid Polish VAT identification number', @@ -48,7 +46,7 @@ final class Nip extends Simple $calculateControlNumber += $digits[$i] * $weights[$i]; } - $calculateControlNumber = $calculateControlNumber % 11; + $calculateControlNumber %= 11; return $targetControlNumber == $calculateControlNumber; } diff --git a/library/Rules/NoWhitespace.php b/library/Rules/NoWhitespace.php index 264a3938..8d2c9528 100644 --- a/library/Rules/NoWhitespace.php +++ b/library/Rules/NoWhitespace.php @@ -13,7 +13,6 @@ use Attribute; use Respect\Validation\Message\Template; use Respect\Validation\Rules\Core\Simple; -use function is_null; use function is_scalar; use function preg_match; @@ -26,7 +25,7 @@ final class NoWhitespace extends Simple { public function isValid(mixed $input): bool { - if (is_null($input)) { + if ($input === null) { return true; } diff --git a/library/Rules/NoneOf.php b/library/Rules/NoneOf.php index 6e70c591..8797c58c 100644 --- a/library/Rules/NoneOf.php +++ b/library/Rules/NoneOf.php @@ -33,17 +33,17 @@ use function count; )] final class NoneOf extends Composite { - public const TEMPLATE_ALL = '__all__'; - public const TEMPLATE_SOME = '__some__'; + public const string TEMPLATE_ALL = '__all__'; + public const string TEMPLATE_SOME = '__some__'; public function evaluate(mixed $input): Result { $children = array_map( - static fn (Rule $rule) => $rule->evaluate($input)->withToggledModeAndValidation(), - $this->rules + static fn(Rule $rule) => $rule->evaluate($input)->withToggledModeAndValidation(), + $this->rules, ); - $valid = array_reduce($children, static fn (bool $carry, Result $result) => $carry && $result->hasPassed, true); - $failed = array_filter($children, static fn (Result $result): bool => !$result->hasPassed); + $valid = array_reduce($children, static fn(bool $carry, Result $result) => $carry && $result->hasPassed, true); + $failed = array_filter($children, static fn(Result $result): bool => !$result->hasPassed); $template = self::TEMPLATE_SOME; if (count($children) === count($failed)) { $template = self::TEMPLATE_ALL; diff --git a/library/Rules/NotEmoji.php b/library/Rules/NotEmoji.php index 0834cbb5..d1ded8ea 100644 --- a/library/Rules/NotEmoji.php +++ b/library/Rules/NotEmoji.php @@ -24,7 +24,7 @@ use function preg_match; )] final class NotEmoji extends Simple { - private const RANGES = [ + private const array RANGES = [ '\x{0023}\x{FE0F}\x{20E3}', '\x{0023}\x{20E3}', '\x{002A}\x{FE0F}\x{20E3}', diff --git a/library/Rules/NullType.php b/library/Rules/NullType.php index e6d2bf80..30c6974b 100644 --- a/library/Rules/NullType.php +++ b/library/Rules/NullType.php @@ -13,8 +13,6 @@ use Attribute; use Respect\Validation\Message\Template; use Respect\Validation\Rules\Core\Simple; -use function is_null; - #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] #[Template( '{{name}} must be null', @@ -24,6 +22,6 @@ final class NullType extends Simple { public function isValid(mixed $input): bool { - return is_null($input); + return $input === null; } } diff --git a/library/Rules/OneOf.php b/library/Rules/OneOf.php index 1eab7bce..bc4f4453 100644 --- a/library/Rules/OneOf.php +++ b/library/Rules/OneOf.php @@ -34,27 +34,27 @@ use function usort; )] final class OneOf extends Composite { - public const TEMPLATE_NONE = '__none__'; - public const TEMPLATE_MORE_THAN_ONE = '__more_than_one__'; + public const string TEMPLATE_NONE = '__none__'; + public const string TEMPLATE_MORE_THAN_ONE = '__more_than_one__'; public function evaluate(mixed $input): Result { - $children = array_map(static fn (Rule $rule) => $rule->evaluate($input), $this->rules); + $children = array_map(static fn(Rule $rule) => $rule->evaluate($input), $this->rules); $valid = array_reduce( $children, - static fn (bool $carry, Result $result) => $carry xor $result->hasPassed, + static fn(bool $carry, Result $result) => $carry xor $result->hasPassed, false, ); - $validChildren = array_filter($children, static fn (Result $result): bool => $result->hasPassed); + $validChildren = array_filter($children, static fn(Result $result): bool => $result->hasPassed); $template = self::TEMPLATE_NONE; if (count($validChildren) > 1) { // Put the failed children at the top, so it makes sense in the main error message - usort($children, static fn (Result $a, Result $b): int => $a->hasPassed <=> $b->hasPassed); + usort($children, static fn(Result $a, Result $b): int => $a->hasPassed <=> $b->hasPassed); $template = self::TEMPLATE_MORE_THAN_ONE; $children = array_map( - static fn (Result $child) => $child->hasPassed ? $child->withToggledValidation() : $child, - $children + static fn(Result $child) => $child->hasPassed ? $child->withToggledValidation() : $child, + $children, ); } diff --git a/library/Rules/Phone.php b/library/Rules/Phone.php index 346e0318..0d942ccf 100644 --- a/library/Rules/Phone.php +++ b/library/Rules/Phone.php @@ -35,17 +35,17 @@ use function is_scalar; )] final class Phone implements Rule { - public const TEMPLATE_FOR_COUNTRY = '__for_country__'; - public const TEMPLATE_INTERNATIONAL = '__international__'; + public const string TEMPLATE_FOR_COUNTRY = '__for_country__'; + public const string TEMPLATE_INTERNATIONAL = '__international__'; - private readonly ?Countries\Country $country; + private readonly Countries\Country|null $country; - public function __construct(?string $countryCode = null, ?Countries $countries = null) + public function __construct(string|null $countryCode = null, Countries|null $countries = null) { if (!class_exists(PhoneNumberUtil::class)) { throw new MissingComposerDependencyException( 'Phone rule libphonenumber for PHP', - 'giggsey/libphonenumber-for-php' + 'giggsey/libphonenumber-for-php', ); } @@ -59,7 +59,7 @@ final class Phone implements Rule throw new MissingComposerDependencyException( 'Phone rule with country code requires PHP ISO Codes', 'sokil/php-isocodes', - 'sokil/php-isocodes-db-only' + 'sokil/php-isocodes-db-only', ); } diff --git a/library/Rules/PolishIdCard.php b/library/Rules/PolishIdCard.php index 511d7dbf..2d59bdb9 100644 --- a/library/Rules/PolishIdCard.php +++ b/library/Rules/PolishIdCard.php @@ -17,9 +17,7 @@ use function is_scalar; use function ord; use function preg_match; -/** - * @see https://en.wikipedia.org/wiki/Polish_identity_card - */ +/** @see https://en.wikipedia.org/wiki/Polish_identity_card */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] #[Template( '{{name}} must be a valid Polish Identity Card number', @@ -27,10 +25,10 @@ use function preg_match; )] final class PolishIdCard extends Simple { - private const ASCII_CODE_0 = 48; - private const ASCII_CODE_7 = 55; - private const ASCII_CODE_9 = 57; - private const ASCII_CODE_A = 65; + private const int ASCII_CODE_0 = 48; + private const int ASCII_CODE_7 = 55; + private const int ASCII_CODE_9 = 57; + private const int ASCII_CODE_A = 65; public function isValid(mixed $input): bool { diff --git a/library/Rules/PortugueseNif.php b/library/Rules/PortugueseNif.php index b3d8dd1a..6fe8b3d1 100644 --- a/library/Rules/PortugueseNif.php +++ b/library/Rules/PortugueseNif.php @@ -23,9 +23,7 @@ use function is_string; use function str_split; use function strlen; -/** - * @see https://pt.wikipedia.org/wiki/N%C3%BAmero_de_identifica%C3%A7%C3%A3o_fiscal - */ +/** @see https://pt.wikipedia.org/wiki/N%C3%BAmero_de_identifica%C3%A7%C3%A3o_fiscal */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] #[Template( '{{name}} must be a Portuguese NIF', @@ -48,7 +46,7 @@ final class PortugueseNif extends Simple return false; } - $digits = array_map(static fn (string $digit) => intval($digit), str_split($input)); + $digits = array_map(static fn(string $digit) => intval($digit), str_split($input)); // Validate first and second digits switch ($digits[0]) { @@ -59,6 +57,7 @@ final class PortugueseNif extends Simple default: return false; } + break; case 7: switch ($digits[1]) { @@ -74,6 +73,7 @@ final class PortugueseNif extends Simple default: return false; } + break; case 9: switch ($digits[1]) { @@ -85,6 +85,7 @@ final class PortugueseNif extends Simple default: return false; } + break; default: break; @@ -93,7 +94,7 @@ final class PortugueseNif extends Simple // Validate check digit $checkDigit = array_pop($digits); $digitKeys = array_keys($digits); - $sumTerms = array_map(static fn (int $digit, int $position) => $digit * (9 - $position), $digits, $digitKeys); + $sumTerms = array_map(static fn(int $digit, int $position) => $digit * (9 - $position), $digits, $digitKeys); $sum = array_sum($sumTerms); $modulus = $sum % 11; diff --git a/library/Rules/PostalCode.php b/library/Rules/PostalCode.php index 801756cc..faeb0806 100644 --- a/library/Rules/PostalCode.php +++ b/library/Rules/PostalCode.php @@ -14,9 +14,7 @@ use Respect\Validation\Exceptions\InvalidRuleConstructorException; use Respect\Validation\Message\Template; use Respect\Validation\Rules\Core\Envelope; -/** - * @see http://download.geonames.org/export/dump/countryInfo.txt - */ +/** @see http://download.geonames.org/export/dump/countryInfo.txt */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] #[Template( '{{name}} must be a valid postal code on {{countryCode}}', @@ -24,9 +22,9 @@ use Respect\Validation\Rules\Core\Envelope; )] final class PostalCode extends Envelope { - private const DEFAULT_PATTERN = '/^$/'; + private const string DEFAULT_PATTERN = '/^$/'; - private const POSTAL_CODES_EXTRA = [ + private const array POSTAL_CODES_EXTRA = [ // phpcs:disable Generic.Files.LineLength.TooLong 'AM' => ['/^\d\d\d\d$/', '/^(\d{4})$/'], 'BR' => ['/^\d\d\d\d\d-\d\d\d$/', '/^\d{5}-?\d{3}$/'], @@ -40,7 +38,7 @@ final class PostalCode extends Envelope // phpcs:enable Generic.Files.LineLength.TooLong ]; - private const POSTAL_CODES = [ + private const array POSTAL_CODES = [ // phpcs:disable Generic.Files.LineLength.TooLong 'AD' => ['/^AD\d\d\d$/', '/^(?:AD)*(\d{3})$/'], 'AL' => ['/^\d\d\d\d$/', '/^(\d{4})$/'], @@ -216,9 +214,9 @@ final class PostalCode extends Envelope parent::__construct( new Regex( - self::POSTAL_CODES_EXTRA[$countryCode][$formatted ? 0 : 1] ?? self::POSTAL_CODES[$countryCode][$formatted ? 0 : 1] ?? self::DEFAULT_PATTERN + self::POSTAL_CODES_EXTRA[$countryCode][$formatted ? 0 : 1] ?? self::POSTAL_CODES[$countryCode][$formatted ? 0 : 1] ?? self::DEFAULT_PATTERN, ), - ['countryCode' => $countryCode] + ['countryCode' => $countryCode], ); } } diff --git a/library/Rules/PropertyExists.php b/library/Rules/PropertyExists.php index 00f6d0d2..bba80de3 100644 --- a/library/Rules/PropertyExists.php +++ b/library/Rules/PropertyExists.php @@ -25,7 +25,7 @@ use function is_object; final readonly class PropertyExists implements Rule { public function __construct( - private string $propertyName + private string $propertyName, ) { } diff --git a/library/Rules/Regex.php b/library/Rules/Regex.php index 8248fb43..30452554 100644 --- a/library/Rules/Regex.php +++ b/library/Rules/Regex.php @@ -25,7 +25,7 @@ use function preg_match; final readonly class Regex implements Rule { public function __construct( - private string $regex + private string $regex, ) { } diff --git a/library/Rules/Size.php b/library/Rules/Size.php index 29d89b04..dcceb073 100644 --- a/library/Rules/Size.php +++ b/library/Rules/Size.php @@ -27,18 +27,18 @@ use function ucfirst; #[Template( 'The size in {{unit|trans}} of', 'The size in {{unit|trans}} of', - Size::TEMPLATE_STANDARD + Size::TEMPLATE_STANDARD, )] #[Template( '{{name}} must be a filename or an instance of SplFileInfo or a PSR-7 interface', '{{name}} must not be a filename or an instance of SplFileInfo or a PSR-7 interface', - self::TEMPLATE_WRONG_TYPE + self::TEMPLATE_WRONG_TYPE, )] final class Size extends Wrapper { - public const TEMPLATE_WRONG_TYPE = '__wrong_type__'; + public const string TEMPLATE_WRONG_TYPE = '__wrong_type__'; - private const DATA_STORAGE_UNITS = [ + private const array DATA_STORAGE_UNITS = [ 'B' => ['name' => 'bytes', 'bytes' => 1], 'KB' => ['name' => 'kilobytes', 'bytes' => 1024], 'MB' => ['name' => 'megabytes', 'bytes' => 1024 ** 2], @@ -53,7 +53,7 @@ final class Size extends Wrapper /** @param "B"|"KB"|"MB"|"GB"|"TB"|"PB"|"EB"|"ZB"|"YB" $unit */ public function __construct( private readonly string $unit, - Rule $rule + Rule $rule, ) { if (!isset(self::DATA_STORAGE_UNITS[$unit])) { throw new InvalidRuleConstructorException('"%s" is not a recognized data storage unit.', $unit); @@ -76,7 +76,7 @@ final class Size extends Wrapper return Result::fromAdjacent($input, 'size', $this, $result, $parameters); } - private function getSize(mixed $input): ?int + private function getSize(mixed $input): int|null { if (is_string($input)) { return (int) filesize($input); diff --git a/library/Rules/Sorted.php b/library/Rules/Sorted.php index d7e5a338..adb24fa8 100644 --- a/library/Rules/Sorted.php +++ b/library/Rules/Sorted.php @@ -34,20 +34,20 @@ use function str_split; )] final readonly class Sorted implements Rule { - public const TEMPLATE_ASCENDING = '__ascending__'; - public const TEMPLATE_DESCENDING = '__descending__'; + public const string TEMPLATE_ASCENDING = '__ascending__'; + public const string TEMPLATE_DESCENDING = '__descending__'; - public const ASCENDING = 'ASC'; - public const DESCENDING = 'DESC'; + public const string ASCENDING = 'ASC'; + public const string DESCENDING = 'DESC'; public function __construct( - private string $direction + private string $direction, ) { if ($direction !== self::ASCENDING && $direction !== self::DESCENDING) { throw new InvalidRuleConstructorException( 'Direction should be either "%s" or "%s"', self::ASCENDING, - self::DESCENDING + self::DESCENDING, ); } } diff --git a/library/Rules/StartsWith.php b/library/Rules/StartsWith.php index 0e04d543..691e65a1 100644 --- a/library/Rules/StartsWith.php +++ b/library/Rules/StartsWith.php @@ -29,7 +29,7 @@ final readonly class StartsWith implements Rule { public function __construct( private mixed $startValue, - private bool $identical = false + private bool $identical = false, ) { } diff --git a/library/Rules/SubdivisionCode.php b/library/Rules/SubdivisionCode.php index 8735e9d2..8f7acf29 100644 --- a/library/Rules/SubdivisionCode.php +++ b/library/Rules/SubdivisionCode.php @@ -34,13 +34,16 @@ final readonly class SubdivisionCode implements Rule private Subdivisions $subdivisions; - public function __construct(string $countryCode, ?Countries $countries = null, ?Subdivisions $subdivisions = null) - { + public function __construct( + string $countryCode, + Countries|null $countries = null, + Subdivisions|null $subdivisions = null, + ) { if (!class_exists(Countries::class) || !class_exists(Subdivisions::class)) { throw new MissingComposerDependencyException( 'SubdivisionCode rule requires PHP ISO Codes', 'sokil/php-isocodes', - 'sokil/php-isocodes-db-only' + 'sokil/php-isocodes-db-only', ); } diff --git a/library/Rules/Subset.php b/library/Rules/Subset.php index 8a04e701..1bf307eb 100644 --- a/library/Rules/Subset.php +++ b/library/Rules/Subset.php @@ -26,7 +26,7 @@ final readonly class Subset implements Rule { /** @param mixed[] $superset */ public function __construct( - private array $superset + private array $superset, ) { } diff --git a/library/Rules/Templated.php b/library/Rules/Templated.php index 3af0df64..c11186b9 100644 --- a/library/Rules/Templated.php +++ b/library/Rules/Templated.php @@ -21,7 +21,7 @@ final class Templated extends Wrapper public function __construct( Rule $rule, private readonly string $template, - private readonly array $parameters = [] + private readonly array $parameters = [], ) { parent::__construct($rule); } diff --git a/library/Rules/Time.php b/library/Rules/Time.php index 4fea1488..a61c3c73 100644 --- a/library/Rules/Time.php +++ b/library/Rules/Time.php @@ -31,7 +31,7 @@ final readonly class Time implements Rule use CanValidateDateTime; public function __construct( - private string $format = 'H:i:s' + private string $format = 'H:i:s', ) { if (!preg_match('/^[gGhHisuvaA\W]+$/', $format)) { throw new InvalidRuleConstructorException('"%s" is not a valid date format', $format); diff --git a/library/Rules/Tld.php b/library/Rules/Tld.php index 43aad3c5..4bcd66fe 100644 --- a/library/Rules/Tld.php +++ b/library/Rules/Tld.php @@ -27,7 +27,7 @@ final class Tld extends Simple /** * List extracted from https://data.iana.org/TLD/tlds-alpha-by-domain.txt */ - private const TLD_LIST = [ + private const array TLD_LIST = [ 'AAA', 'AARP', 'ABB', 'ABBOTT', 'ABBVIE', 'ABC', 'ABLE', 'ABOGADO', 'ABUDHABI', 'AC', 'ACADEMY', 'ACCENTURE', 'ACCOUNTANT', 'ACCOUNTANTS', 'ACO', 'ACTOR', 'AD', 'ADS', 'ADULT', 'AE', 'AEG', 'AERO', 'AETNA', diff --git a/library/Rules/Uuid.php b/library/Rules/Uuid.php index 7f6f85f9..77f2bb0d 100644 --- a/library/Rules/Uuid.php +++ b/library/Rules/Uuid.php @@ -36,18 +36,19 @@ use function is_string; )] final class Uuid implements Rule { - public const TEMPLATE_VERSION = '__version__'; + public const string TEMPLATE_VERSION = '__version__'; public function __construct( - private readonly ?int $version = null + private readonly int|null $version = null, ) { if (!class_exists(RamseyUuid::class)) { throw new MissingComposerDependencyException('Uuid rule requires ramsey/uuid', '='); } + if ($version !== null && !$this->isSupportedVersion($version)) { throw new InvalidRuleConstructorException( 'Only versions 1 to 8 are supported: %d given', - (string)$version + (string) $version, ); } } diff --git a/library/Rules/Version.php b/library/Rules/Version.php index 80b791ae..83eb37c2 100644 --- a/library/Rules/Version.php +++ b/library/Rules/Version.php @@ -16,9 +16,7 @@ use Respect\Validation\Rules\Core\Simple; use function is_string; use function preg_match; -/** - * @see http://semver.org/ - */ +/** @see http://semver.org/ */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] #[Template( '{{name}} must be a version', diff --git a/library/Rules/VideoUrl.php b/library/Rules/VideoUrl.php index 9079faea..f1448212 100644 --- a/library/Rules/VideoUrl.php +++ b/library/Rules/VideoUrl.php @@ -33,9 +33,9 @@ use function preg_match; )] final class VideoUrl implements Rule { - public const TEMPLATE_SERVICE = '__service__'; + public const string TEMPLATE_SERVICE = '__service__'; - private const SERVICES = [ + private const array SERVICES = [ // phpcs:disable Generic.Files.LineLength.TooLong 'youtube' => '@^https?://(www\.)?(?:youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^\"&?/]{11})@i', 'vimeo' => '@^https?://(www\.)?(player\.)?(vimeo\.com/)((channels/[A-z]+/)|(groups/[A-z]+/videos/)|(video/))?([0-9]+)@i', @@ -44,7 +44,7 @@ final class VideoUrl implements Rule ]; public function __construct( - private readonly ?string $service = null + private readonly string|null $service = null, ) { if ($service !== null && !$this->isSupportedService($service)) { throw new InvalidRuleConstructorException('"%s" is not a recognized video service.', $service); diff --git a/library/Rules/When.php b/library/Rules/When.php index 3b153ff2..439b7d20 100644 --- a/library/Rules/When.php +++ b/library/Rules/When.php @@ -19,7 +19,7 @@ final readonly class When implements Rule public function __construct( private Rule $when, private Rule $then, - private Rule $else = new Templated(new AlwaysInvalid(), AlwaysInvalid::TEMPLATE_SIMPLE) + private Rule $else = new Templated(new AlwaysInvalid(), AlwaysInvalid::TEMPLATE_SIMPLE), ) { } diff --git a/library/Rules/Yes.php b/library/Rules/Yes.php index 70c967e4..80e472c4 100644 --- a/library/Rules/Yes.php +++ b/library/Rules/Yes.php @@ -27,7 +27,7 @@ use const YESEXPR; final class Yes extends Simple { public function __construct( - private readonly bool $useLocale = false + private readonly bool $useLocale = false, ) { } diff --git a/library/Transformers/Prefix.php b/library/Transformers/Prefix.php index a2dcd342..482a8556 100644 --- a/library/Transformers/Prefix.php +++ b/library/Transformers/Prefix.php @@ -16,7 +16,7 @@ use function substr; final class Prefix implements Transformer { - private const RULES_TO_SKIP = [ + private const array RULES_TO_SKIP = [ 'key', 'keyExists', 'keyOptional', diff --git a/library/Transformers/RuleSpec.php b/library/Transformers/RuleSpec.php index ce7a8232..a4584d33 100644 --- a/library/Transformers/RuleSpec.php +++ b/library/Transformers/RuleSpec.php @@ -15,7 +15,7 @@ final readonly class RuleSpec public function __construct( public string $name, public array $arguments = [], - public ?RuleSpec $wrapper = null, + public RuleSpec|null $wrapper = null, ) { } } diff --git a/library/Validator.php b/library/Validator.php index 38a19fe7..eb91088e 100644 --- a/library/Validator.php +++ b/library/Validator.php @@ -21,9 +21,7 @@ use function is_array; use function is_callable; use function is_string; -/** - * @mixin Builder - */ +/** @mixin Builder */ final class Validator implements Rule, Nameable { /** @var array */ @@ -32,9 +30,9 @@ final class Validator implements Rule, Nameable /** @var array */ private array $templates = []; - private ?string $name = null; + private string|null $name = null; - private ?string $template = null; + private string|null $template = null; /** @param array $ignoredBacktracePaths */ public function __construct( @@ -51,7 +49,7 @@ final class Validator implements Rule, Nameable ValidatorDefaults::getFactory(), ValidatorDefaults::getFormatter(), ValidatorDefaults::getTranslator(), - ValidatorDefaults::getIgnoredBacktracePaths() + ValidatorDefaults::getIgnoredBacktracePaths(), ); $validator->rules = $rules; @@ -93,7 +91,7 @@ final class Validator implements Rule, Nameable $this->formatter->main($result, $templates, $this->translator), $this->formatter->full($result, $templates, $this->translator), $this->formatter->array($result, $templates, $this->translator), - $this->ignoredBacktracePaths + $this->ignoredBacktracePaths, ); if (!is_callable($template)) { @@ -129,7 +127,7 @@ final class Validator implements Rule, Nameable return $this->rules; } - public function getName(): ?string + public function getName(): string|null { return $this->getRule()->getName() ?? $this->name; } @@ -141,7 +139,7 @@ final class Validator implements Rule, Nameable return $this; } - public function getTemplate(): ?string + public function getTemplate(): string|null { return $this->template; } @@ -153,17 +151,13 @@ final class Validator implements Rule, Nameable return $this; } - /** - * @param mixed[] $arguments - */ + /** @param mixed[] $arguments */ public static function __callStatic(string $ruleName, array $arguments): self { return self::create()->__call($ruleName, $arguments); } - /** - * @param mixed[] $arguments - */ + /** @param mixed[] $arguments */ public function __call(string $ruleName, array $arguments): self { return $this->addRule($this->factory->rule($ruleName, $arguments)); diff --git a/library/ValidatorDefaults.php b/library/ValidatorDefaults.php index ec9aad51..f3241bc1 100644 --- a/library/ValidatorDefaults.php +++ b/library/ValidatorDefaults.php @@ -16,11 +16,11 @@ use Respect\Validation\Message\Translator\DummyTranslator; final class ValidatorDefaults { - private static ?Factory $factory = null; + private static Factory|null $factory = null; - private static ?Formatter $formatter = null; + private static Formatter|null $formatter = null; - private static ?Translator $translator = null; + private static Translator|null $translator = null; /** @var array */ private static array $ignoredBacktracePaths = [__DIR__ . '/Validator.php']; diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 07788f2c..dc438856 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -15,6 +15,15 @@ tests/ + + + tests/bootstrap.php + + library/Rules/Tld.php + + + tests/Pest.php + tests/feature/ @@ -22,13 +31,9 @@ tests/Pest.php tests/feature - - - - - - - + + tests/Pest.php + tests/feature tests/bootstrap.php diff --git a/tests/Pest.php b/tests/Pest.php index 90a02754..2cb1daec 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -65,6 +65,7 @@ function expectDeprecation(Closure $callback, string $error): Closure if ($errno !== E_USER_DEPRECATED) { return false; } + $lastError = $errstr; return true; @@ -91,6 +92,7 @@ function expectMessageAndDeprecation(Closure $callback, string $message, string if ($errno !== E_USER_DEPRECATED) { return false; } + $lastError = $errstr; return true; @@ -105,6 +107,7 @@ function expectMessageAndDeprecation(Closure $callback, string $message, string throw $throwable; } + restore_error_handler(); expect($lastError)->toBe($error); diff --git a/tests/feature/AssertWithKeysTest.php b/tests/feature/AssertWithKeysTest.php index 13fa24bf..ca2da3c8 100644 --- a/tests/feature/AssertWithKeysTest.php +++ b/tests/feature/AssertWithKeysTest.php @@ -48,5 +48,5 @@ test('Scenario #1', catchFullMessage( - `.user` must be a string - `.password` must be a string - `.schema` must be present - FULL_MESSAGE) + FULL_MESSAGE), )); diff --git a/tests/feature/AssertWithPropertiesTest.php b/tests/feature/AssertWithPropertiesTest.php index 9d2bf25b..81793574 100644 --- a/tests/feature/AssertWithPropertiesTest.php +++ b/tests/feature/AssertWithPropertiesTest.php @@ -8,7 +8,7 @@ declare(strict_types=1); test('Scenario #1', catchFullMessage( - fn () => v::create() + fn() => v::create() ->property( 'mysql', v::create() @@ -46,5 +46,5 @@ test('Scenario #1', catchFullMessage( - `.host` must be a string - `.postgresql` must pass the rules - `.user` must be a string - FULL_MESSAGE) + FULL_MESSAGE), )); diff --git a/tests/feature/AssertWithTemplatesTest.php b/tests/feature/AssertWithTemplatesTest.php index 38651e07..df083f0d 100644 --- a/tests/feature/AssertWithTemplatesTest.php +++ b/tests/feature/AssertWithTemplatesTest.php @@ -9,7 +9,7 @@ declare(strict_types=1); test('Template as a string in the chain', catchAll( fn() => v::alwaysInvalid()->setTemplate('My string template in the chain')->assert(1), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('My string template in the chain') ->and($fullMessage)->toBe('- My string template in the chain') ->and($messages)->toBe(['alwaysInvalid' => 'My string template in the chain']), @@ -17,7 +17,7 @@ test('Template as a string in the chain', catchAll( test('Template as an array in the chain', catchAll( fn() => v::alwaysInvalid()->setTemplates(['alwaysInvalid' => 'My array template in the chain'])->assert(1), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('My array template in the chain') ->and($fullMessage)->toBe('- My array template in the chain') ->and($messages)->toBe(['alwaysInvalid' => 'My array template in the chain']), @@ -25,7 +25,7 @@ test('Template as an array in the chain', catchAll( test('Runtime template as string', catchAll( fn() => v::alwaysInvalid()->assert(1, 'My runtime template as string'), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('My runtime template as string') ->and($fullMessage)->toBe('- My runtime template as string') ->and($messages)->toBe(['alwaysInvalid' => 'My runtime template as string']), @@ -33,7 +33,7 @@ test('Runtime template as string', catchAll( test('Runtime template as an array', catchAll( fn() => v::alwaysInvalid()->assert(1, ['alwaysInvalid' => 'My runtime template an array']), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('My runtime template an array') ->and($fullMessage)->toBe('- My runtime template an array') ->and($messages)->toBe(['alwaysInvalid' => 'My runtime template an array']), diff --git a/tests/feature/DoNotRelyOnNestedValidationExceptionInterfaceForCheckTest.php b/tests/feature/DoNotRelyOnNestedValidationExceptionInterfaceForCheckTest.php index af937b38..99cd23cf 100644 --- a/tests/feature/DoNotRelyOnNestedValidationExceptionInterfaceForCheckTest.php +++ b/tests/feature/DoNotRelyOnNestedValidationExceptionInterfaceForCheckTest.php @@ -11,5 +11,5 @@ use Respect\Validation\Validator; test('Scenario #1', catchMessage( fn() => Validator::alnum('__')->lengthBetween(1, 15)->noWhitespace()->assert('really messed up screen#name'), - fn(string $message) => expect($message)->toBe('"really messed up screen#name" must contain only letters (a-z), digits (0-9), and "__"') + fn(string $message) => expect($message)->toBe('"really messed up screen#name" must contain only letters (a-z), digits (0-9), and "__"'), )); diff --git a/tests/feature/GetFullMessageShouldIncludeAllValidationMessagesInAChainTest.php b/tests/feature/GetFullMessageShouldIncludeAllValidationMessagesInAChainTest.php index 02caaf1c..fe162c38 100644 --- a/tests/feature/GetFullMessageShouldIncludeAllValidationMessagesInAChainTest.php +++ b/tests/feature/GetFullMessageShouldIncludeAllValidationMessagesInAChainTest.php @@ -15,5 +15,5 @@ test('Scenario #1', catchFullMessage( - 0 must pass all the rules - 0 must be a string - 0 must be a countable value or a string - FULL_MESSAGE) + FULL_MESSAGE), )); diff --git a/tests/feature/GetMessagesShouldIncludeAllValidationMessagesInAChainTest.php b/tests/feature/GetMessagesShouldIncludeAllValidationMessagesInAChainTest.php index 1b127d1c..d48ff9ac 100644 --- a/tests/feature/GetMessagesShouldIncludeAllValidationMessagesInAChainTest.php +++ b/tests/feature/GetMessagesShouldIncludeAllValidationMessagesInAChainTest.php @@ -10,7 +10,7 @@ declare(strict_types=1); date_default_timezone_set('UTC'); test('Scenario #1', catchMessages( - fn () => v::create() + fn() => v::create() ->key('username', v::lengthBetween(2, 32))->key('birthdate', v::dateTime()) ->key('password', v::notEmpty()) ->key('email', v::email()) @@ -21,5 +21,5 @@ test('Scenario #1', catchMessages( 'birthdate' => '`.birthdate` must be a valid date/time', 'password' => '`.password` must not be empty', 'email' => '`.email` must be present', - ]) + ]), )); diff --git a/tests/feature/GetMessagesTest.php b/tests/feature/GetMessagesTest.php index 0235688e..274b1f59 100644 --- a/tests/feature/GetMessagesTest.php +++ b/tests/feature/GetMessagesTest.php @@ -35,5 +35,5 @@ test('Scenario #1', catchMessages( 'password' => '`.password` must be a string', 'schema' => '`.schema` must be present', ], - ]) + ]), )); diff --git a/tests/feature/GetMessagesWithReplacementsTest.php b/tests/feature/GetMessagesWithReplacementsTest.php index e962d328..66cb4834 100644 --- a/tests/feature/GetMessagesWithReplacementsTest.php +++ b/tests/feature/GetMessagesWithReplacementsTest.php @@ -8,7 +8,7 @@ declare(strict_types=1); test('Scenario #1', catchMessages( - fn () => v::create() + fn() => v::create() ->key( 'mysql', v::create() @@ -41,9 +41,7 @@ test('Scenario #1', catchMessages( 'user' => 'Value should be a MySQL username', 'host' => '`{{name}}` should be a MySQL host', ], - 'postgresql' => [ - 'schema' => 'You must provide a valid PostgreSQL schema', - ], + 'postgresql' => ['schema' => 'You must provide a valid PostgreSQL schema'], ], ), fn(array $messages) => expect($messages)->toBe([ @@ -62,5 +60,5 @@ test('Scenario #1', catchMessages( 'password' => '`.password` must be a string', 'schema' => 'You must provide a valid PostgreSQL schema', ], - ]) + ]), )); diff --git a/tests/feature/Issues/Issue1033Test.php b/tests/feature/Issues/Issue1033Test.php index d807308a..636135d2 100644 --- a/tests/feature/Issues/Issue1033Test.php +++ b/tests/feature/Issues/Issue1033Test.php @@ -22,5 +22,5 @@ test('https://github.com/Respect/Validation/issues/1033', catchAll( 0 => '`.0` must be equal to 1', 1 => '`.1` must be equal to 1', 2 => '`.2` must be equal to 1', - ]) + ]), )); diff --git a/tests/feature/Issues/Issue1244Test.php b/tests/feature/Issues/Issue1244Test.php index cca1533d..8cda4ee1 100644 --- a/tests/feature/Issues/Issue1244Test.php +++ b/tests/feature/Issues/Issue1244Test.php @@ -12,5 +12,5 @@ test('https://github.com/Respect/Validation/issues/1244', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('First Name must be present') ->and($fullMessage)->toBe('- First Name must be present') - ->and($messages)->toBe(['firstname' => 'First Name must be present']) + ->and($messages)->toBe(['firstname' => 'First Name must be present']), )); diff --git a/tests/feature/Issues/Issue1289Test.php b/tests/feature/Issues/Issue1289Test.php index 4a29524e..a2b9af04 100644 --- a/tests/feature/Issues/Issue1289Test.php +++ b/tests/feature/Issues/Issue1289Test.php @@ -64,5 +64,5 @@ test('https://github.com/Respect/Validation/issues/1289', catchAll( ], 'description' => '`.description` must be a string value', ], - ]) + ]), )); diff --git a/tests/feature/Issues/Issue1333Test.php b/tests/feature/Issues/Issue1333Test.php index 7dacbf52..eb6ae006 100644 --- a/tests/feature/Issues/Issue1333Test.php +++ b/tests/feature/Issues/Issue1333Test.php @@ -20,5 +20,5 @@ test('https://github.com/Respect/Validation/issues/1333', catchAll( '__root__' => 'User Email must pass all the rules', 'noWhitespace' => 'User Email must not contain whitespaces', 'email' => 'User Email must be a valid email address', - ]) + ]), )); diff --git a/tests/feature/Issues/Issue1334Test.php b/tests/feature/Issues/Issue1334Test.php index 160d2f04..0e515c6e 100644 --- a/tests/feature/Issues/Issue1334Test.php +++ b/tests/feature/Issues/Issue1334Test.php @@ -46,5 +46,5 @@ test('https://github.com/Respect/Validation/issues/1334', catchAll( 1 => '`.street` must not be empty', 2 => '`.street` must be a string', ], - ]) + ]), )); diff --git a/tests/feature/Issues/Issue1376Test.php b/tests/feature/Issues/Issue1376Test.php index e24af634..3517aef6 100644 --- a/tests/feature/Issues/Issue1376Test.php +++ b/tests/feature/Issues/Issue1376Test.php @@ -35,5 +35,5 @@ test('https://github.com/Respect/Validation/issues/1376', catchAll( 'lengthBetween' => 'The length of `.author` must be between 1 and 2', ], 'user' => '`.user` must be present', - ]) + ]), )); diff --git a/tests/feature/Issues/Issue1469Test.php b/tests/feature/Issues/Issue1469Test.php index 1c7178bd..09fabd9b 100644 --- a/tests/feature/Issues/Issue1469Test.php +++ b/tests/feature/Issues/Issue1469Test.php @@ -8,7 +8,7 @@ declare(strict_types=1); test('https://github.com/Respect/Validation/issues/1469', catchAll( - fn () => v::create() + fn() => v::create() ->arrayVal() ->keySet( v::key( @@ -19,9 +19,9 @@ test('https://github.com/Respect/Validation/issues/1469', catchAll( v::keySet( v::key('product_title', v::stringVal()->notEmpty()), v::key('quantity', v::intVal()->notEmpty()), - ) + ), ) - ->notEmpty() + ->notEmpty(), ), ) ->assert([ @@ -30,9 +30,7 @@ test('https://github.com/Respect/Validation/issues/1469', catchAll( 'product_title' => 'test', 'quantity' => 'test', ], - [ - 'product_title2' => 'test', - ], + ['product_title2' => 'test'], ], ]), fn(string $message, string $fullMessage, array $messages) => expect() @@ -57,9 +55,9 @@ test('https://github.com/Respect/Validation/issues/1469', catchAll( 'product_title2' => '`.product_title2` must not be present', ], ], - ]) + ]), )) -->skip(<<skip(<<<'TEST_SKIP' This test is skipped because the issue is not fixed yet. When changing the path of a `Result` we don't change the path of its children. I took this approach because we don't diff --git a/tests/feature/Issues/Issue1477Test.php b/tests/feature/Issues/Issue1477Test.php index c8de339a..98d72684 100644 --- a/tests/feature/Issues/Issue1477Test.php +++ b/tests/feature/Issues/Issue1477Test.php @@ -10,7 +10,7 @@ declare(strict_types=1); use Respect\Validation\Rules\Core\Simple; test('https://github.com/Respect/Validation/issues/1477', catchAll( - fn () => v::key( + fn() => v::key( 'Address', v::templated( new class extends Simple { @@ -25,5 +25,5 @@ test('https://github.com/Respect/Validation/issues/1477', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.Address` is not good!') ->and($fullMessage)->toBe('- `.Address` is not good!') - ->and($messages)->toBe(['Address' => '`.Address` is not good!']) + ->and($messages)->toBe(['Address' => '`.Address` is not good!']), )); diff --git a/tests/feature/Issues/Issue179Test.php b/tests/feature/Issues/Issue179Test.php index bc49f424..a2b9f735 100644 --- a/tests/feature/Issues/Issue179Test.php +++ b/tests/feature/Issues/Issue179Test.php @@ -34,5 +34,5 @@ test('https://github.com/Respect/Validation/issues/179', catchAll( '__root__' => 'Settings must pass the rules', 'host' => '`.host` must be a string', 'user' => '`.user` must be present', - ]) + ]), )); diff --git a/tests/feature/Issues/Issue425Test.php b/tests/feature/Issues/Issue425Test.php index 20c18e50..41f3a7c2 100644 --- a/tests/feature/Issues/Issue425Test.php +++ b/tests/feature/Issues/Issue425Test.php @@ -17,5 +17,5 @@ test('https://github.com/Respect/Validation/issues/425', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.reference` must be present') ->and($fullMessage)->toBe('- `.reference` must be present') - ->and($messages)->toBe(['reference' => '`.reference` must be present']) + ->and($messages)->toBe(['reference' => '`.reference` must be present']), )); diff --git a/tests/feature/Issues/Issue446Test.php b/tests/feature/Issues/Issue446Test.php index d0e85fdd..3911d5c1 100644 --- a/tests/feature/Issues/Issue446Test.php +++ b/tests/feature/Issues/Issue446Test.php @@ -20,5 +20,5 @@ test('https://github.com/Respect/Validation/issues/446', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The length of `.name` must be between 2 and 32') ->and($fullMessage)->toBe('- The length of `.name` must be between 2 and 32') - ->and($messages)->toBe(['name' => 'The length of `.name` must be between 2 and 32']) + ->and($messages)->toBe(['name' => 'The length of `.name` must be between 2 and 32']), )); diff --git a/tests/feature/Issues/Issue619Test.php b/tests/feature/Issues/Issue619Test.php index 1ac47902..9dd0742f 100644 --- a/tests/feature/Issues/Issue619Test.php +++ b/tests/feature/Issues/Issue619Test.php @@ -12,5 +12,5 @@ test('https://github.com/Respect/Validation/issues/619', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('invalid object') ->and($fullMessage)->toBe('- invalid object') - ->and($messages)->toBe(['instance' => 'invalid object']) + ->and($messages)->toBe(['instance' => 'invalid object']), )); diff --git a/tests/feature/Issues/Issue739Test.php b/tests/feature/Issues/Issue739Test.php index 0626294f..b8be924d 100644 --- a/tests/feature/Issues/Issue739Test.php +++ b/tests/feature/Issues/Issue739Test.php @@ -12,5 +12,5 @@ test('https://github.com/Respect/Validation/issues/739', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"foo" is invalid') ->and($fullMessage)->toBe('- "foo" is invalid') - ->and($messages)->toBe(['alwaysInvalid' => '"foo" is invalid']) + ->and($messages)->toBe(['alwaysInvalid' => '"foo" is invalid']), )); diff --git a/tests/feature/Issues/Issue796Test.php b/tests/feature/Issues/Issue796Test.php index 40c1dfa9..fd935ee3 100644 --- a/tests/feature/Issues/Issue796Test.php +++ b/tests/feature/Issues/Issue796Test.php @@ -53,5 +53,5 @@ test('https://github.com/Respect/Validation/issues/796', catchAll( '__root__' => 'the given data must pass all the rules', 'mysql' => '`.host` must be a string', 'postgresql' => '`.user` must be a string', - ]) + ]), )); diff --git a/tests/feature/Issues/Issue799Test.php b/tests/feature/Issues/Issue799Test.php index f01b48ad..708028db 100644 --- a/tests/feature/Issues/Issue799Test.php +++ b/tests/feature/Issues/Issue799Test.php @@ -29,18 +29,18 @@ test('https://github.com/Respect/Validation/issues/799 | #1', catchAll( '__root__' => '1 must pass all the rules', 'arrayVal' => '1 must be an array value', 'scheme' => '`.scheme` must be present', - ]) + ]), )); test('https://github.com/Respect/Validation/issues/799 | #2', catchAll( fn() => v::create() ->call( - fn ($url) => parse_url((string) $url), + fn($url) => parse_url((string) $url), v::arrayVal()->key('scheme', v::startsWith('https')), ) ->assert($input), fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.scheme` must start with "https"') ->and($fullMessage)->toBe('- `.scheme` must start with "https"') - ->and($messages)->toBe(['scheme' => '`.scheme` must start with "https"']) + ->and($messages)->toBe(['scheme' => '`.scheme` must start with "https"']), )); diff --git a/tests/feature/Issues/Issue805Test.php b/tests/feature/Issues/Issue805Test.php index e7dbf55c..48fb5e16 100644 --- a/tests/feature/Issues/Issue805Test.php +++ b/tests/feature/Issues/Issue805Test.php @@ -12,5 +12,5 @@ test('https://github.com/Respect/Validation/issues/805', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('WRONG EMAIL!!!!!!') ->and($fullMessage)->toBe('- WRONG EMAIL!!!!!!') - ->and($messages)->toBe(['email' => 'WRONG EMAIL!!!!!!']) + ->and($messages)->toBe(['email' => 'WRONG EMAIL!!!!!!']), )); diff --git a/tests/feature/KeysAsValidatorNamesTest.php b/tests/feature/KeysAsValidatorNamesTest.php index ec505928..b7a76b26 100644 --- a/tests/feature/KeysAsValidatorNamesTest.php +++ b/tests/feature/KeysAsValidatorNamesTest.php @@ -10,8 +10,7 @@ declare(strict_types=1); date_default_timezone_set('UTC'); test('Scenario #1', catchFullMessage( - fn () => - v::create() + fn() => v::create() ->key('username', v::length(v::between(2, 32))) ->key('birthdate', v::dateTime()) ->setName('User Subscription Form') @@ -20,5 +19,5 @@ test('Scenario #1', catchFullMessage( - User Subscription Form must pass all the rules - The length of `.username` must be between 2 and 32 - `.birthdate` must be a valid date/time - FULL_MESSAGE) + FULL_MESSAGE), )); diff --git a/tests/feature/NotWithRecursionTest.php b/tests/feature/NotWithRecursionTest.php index 9f35a48d..d6d84795 100644 --- a/tests/feature/NotWithRecursionTest.php +++ b/tests/feature/NotWithRecursionTest.php @@ -19,7 +19,7 @@ test('Scenario #1', catchMessage( ), ), )->assert(2), - fn(string $message) => expect($message)->toBe('2 must not be an integer value') + fn(string $message) => expect($message)->toBe('2 must not be an integer value'), )); test('Scenario #2', catchFullMessage( @@ -38,5 +38,5 @@ test('Scenario #2', catchFullMessage( - 2 must pass the rules - 2 must not be an integer value - 2 must not be a positive number - FULL_MESSAGE) + FULL_MESSAGE), )); diff --git a/tests/feature/Readme/CustomMessagesTest.php b/tests/feature/Readme/CustomMessagesTest.php index db29d3a5..5d8d4a0c 100644 --- a/tests/feature/Readme/CustomMessagesTest.php +++ b/tests/feature/Readme/CustomMessagesTest.php @@ -21,5 +21,5 @@ test('Scenario #1', catchMessages( 'alnum' => '"really messed up screen#name" must contain only letters and digits', 'noWhitespace' => '"really messed up screen#name" cannot contain spaces', 'lengthBetween' => 'The length of "really messed up screen#name" must be between 1 and 15', - ]) + ]), )); diff --git a/tests/feature/Readme/ExampleTest.php b/tests/feature/Readme/ExampleTest.php index ae955205..6d8c4db4 100644 --- a/tests/feature/Readme/ExampleTest.php +++ b/tests/feature/Readme/ExampleTest.php @@ -14,5 +14,5 @@ test('Scenario #1', catchFullMessage( - "really messed up screen#name" must contain only letters (a-z) and digits (0-9) - "really messed up screen#name" must not contain whitespaces - The length of "really messed up screen#name" must be between 1 and 15 - FULL_MESSAGE) + FULL_MESSAGE), )); diff --git a/tests/feature/Readme/GettingMessagesAsAnArrayTest.php b/tests/feature/Readme/GettingMessagesAsAnArrayTest.php index 62573259..2ec49fd3 100644 --- a/tests/feature/Readme/GettingMessagesAsAnArrayTest.php +++ b/tests/feature/Readme/GettingMessagesAsAnArrayTest.php @@ -14,5 +14,5 @@ test('Scenario #1', catchMessages( 'alnum' => '"really messed up screen#name" must contain only letters (a-z) and digits (0-9)', 'noWhitespace' => '"really messed up screen#name" must not contain whitespaces', 'lengthBetween' => 'The length of "really messed up screen#name" must be between 1 and 15', - ]) + ]), )); diff --git a/tests/feature/Rules/AllOfTest.php b/tests/feature/Rules/AllOfTest.php index 9954d7b0..32e31022 100644 --- a/tests/feature/Rules/AllOfTest.php +++ b/tests/feature/Rules/AllOfTest.php @@ -9,7 +9,7 @@ declare(strict_types=1); test('Default: fail, fail', catchAll( fn() => v::allOf(v::intType(), v::negative())->assert('string'), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"string" must be an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - "string" must pass all the rules @@ -25,7 +25,7 @@ test('Default: fail, fail', catchAll( test('Default: fail, pass', catchAll( fn() => v::allOf(v::intType(), v::stringType())->assert('string'), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"string" must be an integer') ->and($fullMessage)->toBe('- "string" must be an integer') ->and($messages)->toBe(['intType' => '"string" must be an integer']), @@ -33,7 +33,7 @@ test('Default: fail, pass', catchAll( test('Default: fail, fail, pass', catchAll( fn() => v::allOf(v::intType(), v::positive(), v::stringType())->assert('string'), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"string" must be an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - "string" must pass the rules @@ -49,7 +49,7 @@ test('Default: fail, fail, pass', catchAll( test('Inverted: pass, pass', catchAll( fn() => v::not(v::allOf(v::intType(), v::negative()))->assert(-1), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('-1 must not be an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - -1 must pass the rules @@ -65,7 +65,7 @@ test('Inverted: pass, pass', catchAll( test('Inverted: pass, fail, fail', catchAll( fn() => v::allOf(v::intType(), v::alpha(), v::stringType())->assert(2), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('2 must contain only letters (a-z)') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - 2 must pass the rules @@ -81,7 +81,7 @@ test('Inverted: pass, fail, fail', catchAll( test('Wrapping "not"', catchAll( fn() => v::allOf(v::not(v::intType()), v::greaterThan(2))->assert(4), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('4 must not be an integer') ->and($fullMessage)->toBe('- 4 must not be an integer') ->and($messages)->toBe(['notIntType' => '4 must not be an integer']), @@ -89,7 +89,7 @@ test('Wrapping "not"', catchAll( test('With a single template', catchAll( fn() => v::allOf(v::stringType(), v::arrayType())->assert(5, 'This is a single template'), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('This is a single template') ->and($fullMessage)->toBe('- This is a single template') ->and($messages)->toBe(['allOf' => 'This is a single template']), @@ -101,7 +101,7 @@ test('With multiple templates', catchAll( 'stringType' => 'Template for "stringType"', 'uppercase' => 'Template for "uppercase"', ]), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Template for "stringType"') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Two things are wrong diff --git a/tests/feature/Rules/AlnumTest.php b/tests/feature/Rules/AlnumTest.php index 9dea5559..9e4d5d01 100644 --- a/tests/feature/Rules/AlnumTest.php +++ b/tests/feature/Rules/AlnumTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::alnum()->assert('abc%1'), - fn (string $message) => expect($message)->toBe('"abc%1" must contain only letters (a-z) and digits (0-9)'), + fn(string $message) => expect($message)->toBe('"abc%1" must contain only letters (a-z) and digits (0-9)'), )); test('Scenario #2', catchMessage( fn() => v::alnum(' ')->assert('abc%2'), - fn (string $message) => expect($message)->toBe('"abc%2" must contain only letters (a-z), digits (0-9), and " "'), + fn(string $message) => expect($message)->toBe('"abc%2" must contain only letters (a-z), digits (0-9), and " "'), )); test('Scenario #3', catchMessage( fn() => v::not(v::alnum())->assert('abcd3'), - fn (string $message) => expect($message)->toBe('"abcd3" must not contain letters (a-z) or digits (0-9)'), + fn(string $message) => expect($message)->toBe('"abcd3" must not contain letters (a-z) or digits (0-9)'), )); test('Scenario #4', catchMessage( fn() => v::not(v::alnum('% '))->assert('abc%4'), - fn (string $message) => expect($message)->toBe('"abc%4" must not contain letters (a-z), digits (0-9), or "% "'), + fn(string $message) => expect($message)->toBe('"abc%4" must not contain letters (a-z), digits (0-9), or "% "'), )); test('Scenario #5', catchFullMessage( fn() => v::alnum()->assert('abc^1'), - fn (string $fullMessage) => expect($fullMessage)->toBe('- "abc^1" must contain only letters (a-z) and digits (0-9)'), + fn(string $fullMessage) => expect($fullMessage)->toBe('- "abc^1" must contain only letters (a-z) and digits (0-9)'), )); test('Scenario #6', catchFullMessage( fn() => v::not(v::alnum())->assert('abcd2'), - fn (string $fullMessage) => expect($fullMessage)->toBe('- "abcd2" must not contain letters (a-z) or digits (0-9)'), + fn(string $fullMessage) => expect($fullMessage)->toBe('- "abcd2" must not contain letters (a-z) or digits (0-9)'), )); test('Scenario #7', catchFullMessage( fn() => v::alnum('* &%')->assert('abc^3'), - fn (string $fullMessage) => expect($fullMessage)->toBe('- "abc^3" must contain only letters (a-z), digits (0-9), and "* &%"'), + fn(string $fullMessage) => expect($fullMessage)->toBe('- "abc^3" must contain only letters (a-z), digits (0-9), and "* &%"'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::alnum('^'))->assert('abc^4'), - fn (string $fullMessage) => expect($fullMessage)->toBe('- "abc^4" must not contain letters (a-z), digits (0-9), or "^"'), + fn(string $fullMessage) => expect($fullMessage)->toBe('- "abc^4" must not contain letters (a-z), digits (0-9), or "^"'), )); diff --git a/tests/feature/Rules/AlphaTest.php b/tests/feature/Rules/AlphaTest.php index 2583bb0b..b58518d7 100644 --- a/tests/feature/Rules/AlphaTest.php +++ b/tests/feature/Rules/AlphaTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::alpha()->assert('aaa%a'), - fn(string $message) => expect($message)->toBe('"aaa%a" must contain only letters (a-z)') + fn(string $message) => expect($message)->toBe('"aaa%a" must contain only letters (a-z)'), )); test('Scenario #2', catchMessage( fn() => v::alpha(' ')->assert('bbb%b'), - fn(string $message) => expect($message)->toBe('"bbb%b" must contain only letters (a-z) and " "') + fn(string $message) => expect($message)->toBe('"bbb%b" must contain only letters (a-z) and " "'), )); test('Scenario #3', catchMessage( fn() => v::not(v::alpha())->assert('ccccc'), - fn(string $message) => expect($message)->toBe('"ccccc" must not contain letters (a-z)') + fn(string $message) => expect($message)->toBe('"ccccc" must not contain letters (a-z)'), )); test('Scenario #4', catchMessage( fn() => v::not(v::alpha('% '))->assert('ddd%d'), - fn(string $message) => expect($message)->toBe('"ddd%d" must not contain letters (a-z) or "% "') + fn(string $message) => expect($message)->toBe('"ddd%d" must not contain letters (a-z) or "% "'), )); test('Scenario #5', catchFullMessage( fn() => v::alpha()->assert('eee^e'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "eee^e" must contain only letters (a-z)') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "eee^e" must contain only letters (a-z)'), )); test('Scenario #6', catchFullMessage( fn() => v::not(v::alpha())->assert('fffff'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "fffff" must not contain letters (a-z)') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "fffff" must not contain letters (a-z)'), )); test('Scenario #7', catchFullMessage( fn() => v::alpha('* &%')->assert('ggg^g'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "ggg^g" must contain only letters (a-z) and "* &%"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "ggg^g" must contain only letters (a-z) and "* &%"'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::alpha('^'))->assert('hhh^h'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "hhh^h" must not contain letters (a-z) or "^"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "hhh^h" must not contain letters (a-z) or "^"'), )); diff --git a/tests/feature/Rules/AlwaysInvalidTest.php b/tests/feature/Rules/AlwaysInvalidTest.php index ccddca98..795f6cb1 100644 --- a/tests/feature/Rules/AlwaysInvalidTest.php +++ b/tests/feature/Rules/AlwaysInvalidTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::alwaysInvalid()->assert('whatever'), - fn(string $message) => expect($message)->toBe('"whatever" must be valid') + fn(string $message) => expect($message)->toBe('"whatever" must be valid'), )); test('Scenario #2', catchFullMessage( fn() => v::alwaysInvalid()->assert(''), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must be valid') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must be valid'), )); diff --git a/tests/feature/Rules/AlwaysValidTest.php b/tests/feature/Rules/AlwaysValidTest.php index e73ea3d6..c97296c3 100644 --- a/tests/feature/Rules/AlwaysValidTest.php +++ b/tests/feature/Rules/AlwaysValidTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::not(v::alwaysValid())->assert(true), - fn(string $message) => expect($message)->toBe('`true` must be invalid') + fn(string $message) => expect($message)->toBe('`true` must be invalid'), )); test('Scenario #2', catchFullMessage( fn() => v::not(v::alwaysValid())->assert(true), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must be invalid') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must be invalid'), )); diff --git a/tests/feature/Rules/AnyOfTest.php b/tests/feature/Rules/AnyOfTest.php index 3224b963..fd3cbffe 100644 --- a/tests/feature/Rules/AnyOfTest.php +++ b/tests/feature/Rules/AnyOfTest.php @@ -20,7 +20,7 @@ test('Default: fail, fail', catchAll( '__root__' => '"string" must pass at least one of the rules', 'intType' => '"string" must be an integer', 'negative' => '"string" must be a negative number', - ]) + ]), )); test('Inverted: pass, pass', catchAll( @@ -36,7 +36,7 @@ test('Inverted: pass, pass', catchAll( '__root__' => '-1 must pass at least one of the rules', 'intType' => '-1 must not be an integer', 'negative' => '-1 must not be a negative number', - ]) + ]), )); test('Inverted: pass, pass, fail', catchAll( @@ -52,5 +52,5 @@ test('Inverted: pass, pass, fail', catchAll( '__root__' => '-1 must pass at least one of the rules', 'intType' => '-1 must not be an integer', 'negative' => '-1 must not be a negative number', - ]) + ]), )); diff --git a/tests/feature/Rules/ArrayTypeTest.php b/tests/feature/Rules/ArrayTypeTest.php index bd22a389..774f10bf 100644 --- a/tests/feature/Rules/ArrayTypeTest.php +++ b/tests/feature/Rules/ArrayTypeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::arrayType()->assert('teste'), - fn(string $message) => expect($message)->toBe('"teste" must be an array') + fn(string $message) => expect($message)->toBe('"teste" must be an array'), )); test('Scenario #2', catchMessage( fn() => v::not(v::arrayType())->assert([]), - fn(string $message) => expect($message)->toBe('`[]` must not be an array') + fn(string $message) => expect($message)->toBe('`[]` must not be an array'), )); test('Scenario #3', catchFullMessage( fn() => v::arrayType()->assert(new ArrayObject()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `ArrayObject { getArrayCopy() => [] }` must be an array') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `ArrayObject { getArrayCopy() => [] }` must be an array'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::arrayType())->assert([1, 2, 3]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[1, 2, 3]` must not be an array') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[1, 2, 3]` must not be an array'), )); diff --git a/tests/feature/Rules/ArrayValTest.php b/tests/feature/Rules/ArrayValTest.php index 991b0fff..101eb216 100644 --- a/tests/feature/Rules/ArrayValTest.php +++ b/tests/feature/Rules/ArrayValTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::arrayVal()->assert('Bla %123'), - fn(string $message) => expect($message)->toBe('"Bla %123" must be an array value') + fn(string $message) => expect($message)->toBe('"Bla %123" must be an array value'), )); test('Scenario #2', catchMessage( fn() => v::not(v::arrayVal())->assert([42]), - fn(string $message) => expect($message)->toBe('`[42]` must not be an array value') + fn(string $message) => expect($message)->toBe('`[42]` must not be an array value'), )); test('Scenario #3', catchFullMessage( fn() => v::arrayVal()->assert(new stdClass()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be an array value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be an array value'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::arrayVal())->assert(new ArrayObject([2, 3])), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `ArrayObject { getArrayCopy() => [2, 3] }` must not be an array value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `ArrayObject { getArrayCopy() => [2, 3] }` must not be an array value'), )); diff --git a/tests/feature/Rules/AttributesTest.php b/tests/feature/Rules/AttributesTest.php index ee086a67..12ff012d 100644 --- a/tests/feature/Rules/AttributesTest.php +++ b/tests/feature/Rules/AttributesTest.php @@ -14,7 +14,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.name` must not be empty') ->and($fullMessage)->toBe('- `.name` must not be empty') - ->and($messages)->toBe(['name' => '`.name` must not be empty']) + ->and($messages)->toBe(['name' => '`.name` must not be empty']), )); test('Inverted', catchAll( @@ -22,7 +22,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.phone` must be a valid telephone number or must be null') ->and($fullMessage)->toBe('- `.phone` must be a valid telephone number or must be null') - ->and($messages)->toBe(['phone' => '`.phone` must be a valid telephone number or must be null']) + ->and($messages)->toBe(['phone' => '`.phone` must be a valid telephone number or must be null']), )); test('Not an object', catchAll( @@ -30,7 +30,7 @@ test('Not an object', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`[]` must be an object') ->and($fullMessage)->toBe('- `[]` must be an object') - ->and($messages)->toBe(['attributes' => '`[]` must be an object']) + ->and($messages)->toBe(['attributes' => '`[]` must be an object']), )); test('Nullable', catchAll( @@ -38,7 +38,7 @@ test('Nullable', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.phone` must be a valid telephone number or must be null') ->and($fullMessage)->toBe('- `.phone` must be a valid telephone number or must be null') - ->and($messages)->toBe(['phone' => '`.phone` must be a valid telephone number or must be null']) + ->and($messages)->toBe(['phone' => '`.phone` must be a valid telephone number or must be null']), )); test('Multiple attributes, all failed', catchAll( @@ -64,7 +64,7 @@ test('Multiple attributes, all failed', catchAll( ], 'email' => '`.email` must be a valid email address or must be null', 'phone' => '`.phone` must be a valid telephone number or must be null', - ]) + ]), )); test('Failed attributes on the class', catchAll( @@ -82,7 +82,7 @@ test('Failed attributes on the class', catchAll( 'email' => '`.email` must be defined', 'phone' => '`.phone` must be defined', ], - ]) + ]), )); test('Multiple attributes, one failed', catchAll( @@ -90,5 +90,5 @@ test('Multiple attributes, one failed', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.birthdate` must be a valid date in the format "2005-12-30"') ->and($fullMessage)->toBe('- `.birthdate` must be a valid date in the format "2005-12-30"') - ->and($messages)->toBe(['birthdate' => '`.birthdate` must be a valid date in the format "2005-12-30"']) + ->and($messages)->toBe(['birthdate' => '`.birthdate` must be a valid date in the format "2005-12-30"']), )); diff --git a/tests/feature/Rules/Base64Test.php b/tests/feature/Rules/Base64Test.php index 84ded15d..2d5f674e 100644 --- a/tests/feature/Rules/Base64Test.php +++ b/tests/feature/Rules/Base64Test.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::base64()->assert('=c3VyZS4'), - fn(string $message) => expect($message)->toBe('"=c3VyZS4" must be a base64 encoded string') + fn(string $message) => expect($message)->toBe('"=c3VyZS4" must be a base64 encoded string'), )); test('Scenario #2', catchMessage( fn() => v::not(v::base64())->assert('c3VyZS4='), - fn(string $message) => expect($message)->toBe('"c3VyZS4=" must not be a base64 encoded string') + fn(string $message) => expect($message)->toBe('"c3VyZS4=" must not be a base64 encoded string'), )); test('Scenario #3', catchFullMessage( fn() => v::base64()->assert('=c3VyZS4'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "=c3VyZS4" must be a base64 encoded string') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "=c3VyZS4" must be a base64 encoded string'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::base64())->assert('c3VyZS4='), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "c3VyZS4=" must not be a base64 encoded string') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "c3VyZS4=" must not be a base64 encoded string'), )); diff --git a/tests/feature/Rules/BaseTest.php b/tests/feature/Rules/BaseTest.php index b6d62056..6cd89167 100644 --- a/tests/feature/Rules/BaseTest.php +++ b/tests/feature/Rules/BaseTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::base(61)->assert('Z01xSsg5675hic20dj'), - fn(string $message) => expect($message)->toBe('"Z01xSsg5675hic20dj" must be a number in base 61') + fn(string $message) => expect($message)->toBe('"Z01xSsg5675hic20dj" must be a number in base 61'), )); test('Scenario #2', catchFullMessage( fn() => v::base(2)->assert(''), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must be a number in base 2') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must be a number in base 2'), )); test('Scenario #3', catchMessage( fn() => v::not(v::base(2))->assert('011010001'), - fn(string $message) => expect($message)->toBe('"011010001" must not be a number in base 2') + fn(string $message) => expect($message)->toBe('"011010001" must not be a number in base 2'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::base(2))->assert('011010001'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "011010001" must not be a number in base 2') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "011010001" must not be a number in base 2'), )); diff --git a/tests/feature/Rules/BeetwenTest.php b/tests/feature/Rules/BeetwenTest.php index f509438e..1197a3e0 100644 --- a/tests/feature/Rules/BeetwenTest.php +++ b/tests/feature/Rules/BeetwenTest.php @@ -9,30 +9,30 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::between(1, 2)->assert(0), - fn(string $message) => expect($message)->toBe('0 must be between 1 and 2') + fn(string $message) => expect($message)->toBe('0 must be between 1 and 2'), )); test('Scenario #2', catchMessage( fn() => v::not(v::between('yesterday', 'tomorrow'))->assert('today'), - fn(string $message) => expect($message)->toBe('"today" must not be between "yesterday" and "tomorrow"') + fn(string $message) => expect($message)->toBe('"today" must not be between "yesterday" and "tomorrow"'), )); test('Scenario #3', catchFullMessage( fn() => v::between('a', 'c')->assert('d'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "d" must be between "a" and "c"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "d" must be between "a" and "c"'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::between(-INF, INF))->assert(0), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 0 must not be between `-INF` and `INF`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 0 must not be between `-INF` and `INF`'), )); test('Scenario #5', catchFullMessage( fn() => v::not(v::between('a', 'b'))->assert('a'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must not be between "a" and "b"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must not be between "a" and "b"'), )); test('Scenario #6', catchFullMessage( fn() => v::not(v::between(1, 42))->assert(41), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 41 must not be between 1 and 42') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 41 must not be between 1 and 42'), )); diff --git a/tests/feature/Rules/BetweenExclusiveTest.php b/tests/feature/Rules/BetweenExclusiveTest.php index b62db26d..9e17ad17 100644 --- a/tests/feature/Rules/BetweenExclusiveTest.php +++ b/tests/feature/Rules/BetweenExclusiveTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('12 must be greater than 1 and less than 10') ->and($fullMessage)->toBe('- 12 must be greater than 1 and less than 10') - ->and($messages)->toBe(['betweenExclusive' => '12 must be greater than 1 and less than 10']) + ->and($messages)->toBe(['betweenExclusive' => '12 must be greater than 1 and less than 10']), )); test('Inverted', catchAll( @@ -20,7 +20,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('5 must not be greater than 1 or less than 10') ->and($fullMessage)->toBe('- 5 must not be greater than 1 or less than 10') - ->and($messages)->toBe(['notBetweenExclusive' => '5 must not be greater than 1 or less than 10']) + ->and($messages)->toBe(['notBetweenExclusive' => '5 must not be greater than 1 or less than 10']), )); test('With template', catchAll( @@ -28,7 +28,7 @@ test('With template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Bewildered bees buzzed between blooming begonias') ->and($fullMessage)->toBe('- Bewildered bees buzzed between blooming begonias') - ->and($messages)->toBe(['betweenExclusive' => 'Bewildered bees buzzed between blooming begonias']) + ->and($messages)->toBe(['betweenExclusive' => 'Bewildered bees buzzed between blooming begonias']), )); test('With name', catchAll( @@ -36,5 +36,5 @@ test('With name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Range must be greater than 1 and less than 10') ->and($fullMessage)->toBe('- Range must be greater than 1 and less than 10') - ->and($messages)->toBe(['betweenExclusive' => 'Range must be greater than 1 and less than 10']) + ->and($messages)->toBe(['betweenExclusive' => 'Range must be greater than 1 and less than 10']), )); diff --git a/tests/feature/Rules/BoolTypeTest.php b/tests/feature/Rules/BoolTypeTest.php index 23a674e2..bd08d791 100644 --- a/tests/feature/Rules/BoolTypeTest.php +++ b/tests/feature/Rules/BoolTypeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::boolType()->assert('teste'), - fn(string $message) => expect($message)->toBe('"teste" must be a boolean') + fn(string $message) => expect($message)->toBe('"teste" must be a boolean'), )); test('Scenario #2', catchMessage( fn() => v::not(v::boolType())->assert(true), - fn(string $message) => expect($message)->toBe('`true` must not be a boolean') + fn(string $message) => expect($message)->toBe('`true` must not be a boolean'), )); test('Scenario #3', catchFullMessage( fn() => v::boolType()->assert([]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[]` must be a boolean') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[]` must be a boolean'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::boolType())->assert(false), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `false` must not be a boolean') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `false` must not be a boolean'), )); diff --git a/tests/feature/Rules/BoolValTest.php b/tests/feature/Rules/BoolValTest.php index 64d4171b..4ac69b08 100644 --- a/tests/feature/Rules/BoolValTest.php +++ b/tests/feature/Rules/BoolValTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::boolVal()->assert('ok'), - fn(string $message) => expect($message)->toBe('"ok" must be a boolean value') + fn(string $message) => expect($message)->toBe('"ok" must be a boolean value'), )); test('Scenario #2', catchMessage( fn() => v::not(v::boolVal())->assert('yes'), - fn(string $message) => expect($message)->toBe('"yes" must not be a boolean value') + fn(string $message) => expect($message)->toBe('"yes" must not be a boolean value'), )); test('Scenario #3', catchFullMessage( fn() => v::boolVal()->assert('yep'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "yep" must be a boolean value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "yep" must be a boolean value'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::boolVal())->assert('on'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "on" must not be a boolean value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "on" must not be a boolean value'), )); diff --git a/tests/feature/Rules/BsnTest.php b/tests/feature/Rules/BsnTest.php index bf8db01b..3c868476 100644 --- a/tests/feature/Rules/BsnTest.php +++ b/tests/feature/Rules/BsnTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::bsn()->assert('acb'), - fn(string $message) => expect($message)->toBe('"acb" must be a valid BSN') + fn(string $message) => expect($message)->toBe('"acb" must be a valid BSN'), )); test('Scenario #2', catchMessage( fn() => v::not(v::bsn())->assert('612890053'), - fn(string $message) => expect($message)->toBe('"612890053" must not be a valid BSN') + fn(string $message) => expect($message)->toBe('"612890053" must not be a valid BSN'), )); test('Scenario #3', catchFullMessage( fn() => v::bsn()->assert('abc'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "abc" must be a valid BSN') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "abc" must be a valid BSN'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::bsn())->assert('612890053'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "612890053" must not be a valid BSN') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "612890053" must not be a valid BSN'), )); diff --git a/tests/feature/Rules/CallTest.php b/tests/feature/Rules/CallTest.php index 75da306a..a5118719 100644 --- a/tests/feature/Rules/CallTest.php +++ b/tests/feature/Rules/CallTest.php @@ -9,30 +9,30 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::call('trim', v::noWhitespace())->assert(' two words '), - fn(string $message) => expect($message)->toBe('"two words" must not contain whitespaces') + fn(string $message) => expect($message)->toBe('"two words" must not contain whitespaces'), )); test('Scenario #2', catchMessage( fn() => v::not(v::call('stripslashes', v::stringType()))->assert(' some\thing '), - fn(string $message) => expect($message)->toBe('" something " must not be a string') + fn(string $message) => expect($message)->toBe('" something " must not be a string'), )); test('Scenario #3', catchMessage( fn() => v::call('stripslashes', v::alwaysValid())->assert([]), - fn(string $message) => expect($message)->toBe('`[]` must be a suitable argument for "stripslashes"') + fn(string $message) => expect($message)->toBe('`[]` must be a suitable argument for "stripslashes"'), )); test('Scenario #4', catchFullMessage( fn() => v::call('strval', v::intType())->assert(1234), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1234" must be an integer') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1234" must be an integer'), )); test('Scenario #5', catchFullMessage( fn() => v::not(v::call('is_float', v::boolType()))->assert(1.2), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must not be a boolean') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must not be a boolean'), )); test('Scenario #6', catchFullMessage( fn() => v::call('array_shift', v::alwaysValid())->assert(INF), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `INF` must be a suitable argument for "array_shift"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `INF` must be a suitable argument for "array_shift"'), )); diff --git a/tests/feature/Rules/CallableTypeTest.php b/tests/feature/Rules/CallableTypeTest.php index cb7c743b..cecb0d52 100644 --- a/tests/feature/Rules/CallableTypeTest.php +++ b/tests/feature/Rules/CallableTypeTest.php @@ -9,22 +9,22 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::callableType()->assert([]), - fn(string $message) => expect($message)->toBe('`[]` must be a callable') + fn(string $message) => expect($message)->toBe('`[]` must be a callable'), )); test('Scenario #2', catchMessage( fn() => v::not(v::callableType())->assert('trim'), - fn(string $message) => expect($message)->toBe('"trim" must not be a callable') + fn(string $message) => expect($message)->toBe('"trim" must not be a callable'), )); test('Scenario #3', catchFullMessage( fn() => v::callableType()->assert(true), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must be a callable') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must be a callable'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::callableType())->assert(function (): void { // Do nothing }), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `Closure {}` must not be a callable') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `Closure {}` must not be a callable'), )); diff --git a/tests/feature/Rules/CallbackTest.php b/tests/feature/Rules/CallbackTest.php index c7addf79..28e634ca 100644 --- a/tests/feature/Rules/CallbackTest.php +++ b/tests/feature/Rules/CallbackTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::callback('is_string')->assert([]), - fn(string $message) => expect($message)->toBe('`[]` must be valid') + fn(string $message) => expect($message)->toBe('`[]` must be valid'), )); test('Scenario #2', catchMessage( fn() => v::not(v::callback('is_string'))->assert('foo'), - fn(string $message) => expect($message)->toBe('"foo" must be invalid') + fn(string $message) => expect($message)->toBe('"foo" must be invalid'), )); test('Scenario #3', catchFullMessage( fn() => v::callback('is_string')->assert(true), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must be valid') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must be valid'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::callback('is_string'))->assert('foo'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "foo" must be invalid') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "foo" must be invalid'), )); diff --git a/tests/feature/Rules/CharsetTest.php b/tests/feature/Rules/CharsetTest.php index a43384f3..4579caff 100644 --- a/tests/feature/Rules/CharsetTest.php +++ b/tests/feature/Rules/CharsetTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::charset('ASCII')->assert('açaí'), - fn(string $message) => expect($message)->toBe('"açaí" must only contain characters from the `["ASCII"]` charset') + fn(string $message) => expect($message)->toBe('"açaí" must only contain characters from the `["ASCII"]` charset'), )); test('Scenario #2', catchMessage( fn() => v::not(v::charset('UTF-8'))->assert('açaí'), - fn(string $message) => expect($message)->toBe('"açaí" must not contain any characters from the `["UTF-8"]` charset') + fn(string $message) => expect($message)->toBe('"açaí" must not contain any characters from the `["UTF-8"]` charset'), )); test('Scenario #3', catchFullMessage( fn() => v::charset('ASCII')->assert('açaí'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "açaí" must only contain characters from the `["ASCII"]` charset') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "açaí" must only contain characters from the `["ASCII"]` charset'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::charset('UTF-8'))->assert('açaí'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "açaí" must not contain any characters from the `["UTF-8"]` charset') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "açaí" must not contain any characters from the `["UTF-8"]` charset'), )); diff --git a/tests/feature/Rules/CircuitTest.php b/tests/feature/Rules/CircuitTest.php index 65e1b5b6..5a2446e4 100644 --- a/tests/feature/Rules/CircuitTest.php +++ b/tests/feature/Rules/CircuitTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`false` must evaluate to `true`') ->and($fullMessage)->toBe('- `false` must evaluate to `true`') - ->and($messages)->toBe(['trueVal' => '`false` must evaluate to `true`']) + ->and($messages)->toBe(['trueVal' => '`false` must evaluate to `true`']), )); test('Inverted', catchAll( @@ -20,7 +20,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`true` must not evaluate to `true`') ->and($fullMessage)->toBe('- `true` must not evaluate to `true`') - ->and($messages)->toBe(['notTrueVal' => '`true` must not evaluate to `true`']) + ->and($messages)->toBe(['notTrueVal' => '`true` must not evaluate to `true`']), )); test('Default with inverted failing rule', catchAll( @@ -28,7 +28,7 @@ test('Default with inverted failing rule', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`true` must not evaluate to `true`') ->and($fullMessage)->toBe('- `true` must not evaluate to `true`') - ->and($messages)->toBe(['notTrueVal' => '`true` must not evaluate to `true`']) + ->and($messages)->toBe(['notTrueVal' => '`true` must not evaluate to `true`']), )); test('With wrapped name, default', catchAll( @@ -36,7 +36,7 @@ test('With wrapped name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must evaluate to `true`') ->and($fullMessage)->toBe('- Wrapped must evaluate to `true`') - ->and($messages)->toBe(['trueVal' => 'Wrapped must evaluate to `true`']) + ->and($messages)->toBe(['trueVal' => 'Wrapped must evaluate to `true`']), )); test('With wrapper name, default', catchAll( @@ -44,7 +44,7 @@ test('With wrapper name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must evaluate to `true`') ->and($fullMessage)->toBe('- Wrapper must evaluate to `true`') - ->and($messages)->toBe(['trueVal' => 'Wrapper must evaluate to `true`']) + ->and($messages)->toBe(['trueVal' => 'Wrapper must evaluate to `true`']), )); test('With the name set in the wrapped rule of an inverted failing rule', catchAll( @@ -52,7 +52,7 @@ test('With the name set in the wrapped rule of an inverted failing rule', catchA fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must not evaluate to `true`') ->and($fullMessage)->toBe('- Wrapped must not evaluate to `true`') - ->and($messages)->toBe(['notTrueVal' => 'Wrapped must not evaluate to `true`']) + ->and($messages)->toBe(['notTrueVal' => 'Wrapped must not evaluate to `true`']), )); test('With the name set in an inverted failing rule', catchAll( @@ -60,7 +60,7 @@ test('With the name set in an inverted failing rule', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not must not evaluate to `true`') ->and($fullMessage)->toBe('- Not must not evaluate to `true`') - ->and($messages)->toBe(['notTrueVal' => 'Not must not evaluate to `true`']) + ->and($messages)->toBe(['notTrueVal' => 'Not must not evaluate to `true`']), )); test('With the name set in the "circuit" that has an inverted failing rule', catchAll( @@ -68,7 +68,7 @@ test('With the name set in the "circuit" that has an inverted failing rule', cat fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must not evaluate to `true`') ->and($fullMessage)->toBe('- Wrapper must not evaluate to `true`') - ->and($messages)->toBe(['notTrueVal' => 'Wrapper must not evaluate to `true`']) + ->and($messages)->toBe(['notTrueVal' => 'Wrapper must not evaluate to `true`']), )); test('With template', catchAll( @@ -78,7 +78,7 @@ test('With template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Circuit cool cats cunningly continuous cookies') ->and($fullMessage)->toBe('- Circuit cool cats cunningly continuous cookies') - ->and($messages)->toBe(['trueVal' => 'Circuit cool cats cunningly continuous cookies']) + ->and($messages)->toBe(['trueVal' => 'Circuit cool cats cunningly continuous cookies']), )); test('With multiple templates', catchAll( @@ -88,18 +88,18 @@ test('With multiple templates', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Clever clowns craft circuit clever clocks') ->and($fullMessage)->toBe('- Clever clowns craft circuit clever clocks') - ->and($messages)->toBe(['trueVal' => 'Clever clowns craft circuit clever clocks']) + ->and($messages)->toBe(['trueVal' => 'Clever clowns craft circuit clever clocks']), )); test('Real example', catchAll( fn() => v::circuit( v::key('countyCode', v::countryCode()), v::lazy( - fn ($input) => v::key('subdivisionCode', v::subdivisionCode($input['countyCode'])) + fn($input) => v::key('subdivisionCode', v::subdivisionCode($input['countyCode'])), ), )->assert(['countyCode' => 'BR', 'subdivisionCode' => 'CA']), fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.subdivisionCode` must be a subdivision code of Brazil') ->and($fullMessage)->toBe('- `.subdivisionCode` must be a subdivision code of Brazil') - ->and($messages)->toBe(['subdivisionCode' => '`.subdivisionCode` must be a subdivision code of Brazil']) + ->and($messages)->toBe(['subdivisionCode' => '`.subdivisionCode` must be a subdivision code of Brazil']), )); diff --git a/tests/feature/Rules/CnhTest.php b/tests/feature/Rules/CnhTest.php index d460d487..b3e76f52 100644 --- a/tests/feature/Rules/CnhTest.php +++ b/tests/feature/Rules/CnhTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::cnh()->assert('batman'), - fn(string $message) => expect($message)->toBe('"batman" must be a valid CNH number') + fn(string $message) => expect($message)->toBe('"batman" must be a valid CNH number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::cnh())->assert('02650306461'), - fn(string $message) => expect($message)->toBe('"02650306461" must not be a valid CNH number') + fn(string $message) => expect($message)->toBe('"02650306461" must not be a valid CNH number'), )); test('Scenario #3', catchFullMessage( fn() => v::cnh()->assert('bruce wayne'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "bruce wayne" must be a valid CNH number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "bruce wayne" must be a valid CNH number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::cnh())->assert('02650306461'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "02650306461" must not be a valid CNH number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "02650306461" must not be a valid CNH number'), )); diff --git a/tests/feature/Rules/CnpjTest.php b/tests/feature/Rules/CnpjTest.php index 5041fd05..f136e65e 100644 --- a/tests/feature/Rules/CnpjTest.php +++ b/tests/feature/Rules/CnpjTest.php @@ -11,20 +11,20 @@ require_once 'vendor/autoload.php'; test('Scenario #1', catchMessage( fn() => v::cnpj()->assert('não cnpj'), - fn(string $message) => expect($message)->toBe('"não cnpj" must be a valid CNPJ number') + fn(string $message) => expect($message)->toBe('"não cnpj" must be a valid CNPJ number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::cnpj())->assert('65.150.175/0001-20'), - fn(string $message) => expect($message)->toBe('"65.150.175/0001-20" must not be a valid CNPJ number') + fn(string $message) => expect($message)->toBe('"65.150.175/0001-20" must not be a valid CNPJ number'), )); test('Scenario #3', catchFullMessage( fn() => v::cnpj()->assert('test'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "test" must be a valid CNPJ number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "test" must be a valid CNPJ number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::cnpj())->assert('65.150.175/0001-20'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "65.150.175/0001-20" must not be a valid CNPJ number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "65.150.175/0001-20" must not be a valid CNPJ number'), )); diff --git a/tests/feature/Rules/CntrlTest.php b/tests/feature/Rules/CntrlTest.php index 2d90e653..cbfe169f 100644 --- a/tests/feature/Rules/CntrlTest.php +++ b/tests/feature/Rules/CntrlTest.php @@ -11,40 +11,40 @@ require_once 'vendor/autoload.php'; test('Scenario #1', catchMessage( fn() => v::control()->assert('16-50'), - fn(string $message) => expect($message)->toBe('"16-50" must only contain control characters') + fn(string $message) => expect($message)->toBe('"16-50" must only contain control characters'), )); test('Scenario #2', catchMessage( fn() => v::control('16')->assert('16-50'), - fn(string $message) => expect($message)->toBe('"16-50" must only contain control characters and "16"') + fn(string $message) => expect($message)->toBe('"16-50" must only contain control characters and "16"'), )); test('Scenario #3', catchMessage( fn() => v::not(v::control())->assert("\n"), - fn(string $message) => expect($message)->toBe('"\\n" must not contain control characters') + fn(string $message) => expect($message)->toBe('"\\n" must not contain control characters'), )); test('Scenario #4', catchMessage( fn() => v::not(v::control('16'))->assert("16\n"), - fn(string $message) => expect($message)->toBe('"16\\n" must not contain control characters or "16"') + fn(string $message) => expect($message)->toBe('"16\\n" must not contain control characters or "16"'), )); test('Scenario #5', catchFullMessage( fn() => v::control()->assert('Foo'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "Foo" must only contain control characters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "Foo" must only contain control characters'), )); test('Scenario #6', catchFullMessage( fn() => v::control('Bar')->assert('Foo'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "Foo" must only contain control characters and "Bar"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "Foo" must only contain control characters and "Bar"'), )); test('Scenario #7', catchFullMessage( fn() => v::not(v::control())->assert("\n"), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "\\n" must not contain control characters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "\\n" must not contain control characters'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::control('Bar'))->assert("Bar\n"), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "Bar\\n" must not contain control characters or "Bar"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "Bar\\n" must not contain control characters or "Bar"'), )); diff --git a/tests/feature/Rules/ConsonantTest.php b/tests/feature/Rules/ConsonantTest.php index 7be5545a..b8443dbe 100644 --- a/tests/feature/Rules/ConsonantTest.php +++ b/tests/feature/Rules/ConsonantTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::consonant()->assert('aeiou'), - fn(string $message) => expect($message)->toBe('"aeiou" must only contain consonants') + fn(string $message) => expect($message)->toBe('"aeiou" must only contain consonants'), )); test('Scenario #2', catchMessage( fn() => v::consonant('d')->assert('daeiou'), - fn(string $message) => expect($message)->toBe('"daeiou" must only contain consonants and "d"') + fn(string $message) => expect($message)->toBe('"daeiou" must only contain consonants and "d"'), )); test('Scenario #3', catchMessage( fn() => v::not(v::consonant())->assert('bcd'), - fn(string $message) => expect($message)->toBe('"bcd" must not contain consonants') + fn(string $message) => expect($message)->toBe('"bcd" must not contain consonants'), )); test('Scenario #4', catchMessage( fn() => v::not(v::consonant('a'))->assert('abcd'), - fn(string $message) => expect($message)->toBe('"abcd" must not contain consonants or "a"') + fn(string $message) => expect($message)->toBe('"abcd" must not contain consonants or "a"'), )); test('Scenario #5', catchFullMessage( fn() => v::consonant()->assert('aeiou'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "aeiou" must only contain consonants') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "aeiou" must only contain consonants'), )); test('Scenario #6', catchFullMessage( fn() => v::consonant('d')->assert('daeiou'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "daeiou" must only contain consonants and "d"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "daeiou" must only contain consonants and "d"'), )); test('Scenario #7', catchFullMessage( fn() => v::not(v::consonant())->assert('bcd'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "bcd" must not contain consonants') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "bcd" must not contain consonants'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::consonant('a'))->assert('abcd'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "abcd" must not contain consonants or "a"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "abcd" must not contain consonants or "a"'), )); diff --git a/tests/feature/Rules/ContainsAnyTest.php b/tests/feature/Rules/ContainsAnyTest.php index 85982826..07ba9990 100644 --- a/tests/feature/Rules/ContainsAnyTest.php +++ b/tests/feature/Rules/ContainsAnyTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::containsAny(['foo', 'bar'])->assert('baz'), - fn(string $message) => expect($message)->toBe('"baz" must contain at least one value from `["foo", "bar"]`') + fn(string $message) => expect($message)->toBe('"baz" must contain at least one value from `["foo", "bar"]`'), )); test('Scenario #2', catchMessage( fn() => v::not(v::containsAny(['foo', 'bar']))->assert('fool'), - fn(string $message) => expect($message)->toBe('"fool" must not contain any value from `["foo", "bar"]`') + fn(string $message) => expect($message)->toBe('"fool" must not contain any value from `["foo", "bar"]`'), )); test('Scenario #3', catchFullMessage( fn() => v::containsAny(['foo', 'bar'])->assert(['baz']), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `["baz"]` must contain at least one value from `["foo", "bar"]`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `["baz"]` must contain at least one value from `["foo", "bar"]`'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::containsAny(['foo', 'bar'], true))->assert(['bar', 'foo']), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `["bar", "foo"]` must not contain any value from `["foo", "bar"]`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `["bar", "foo"]` must not contain any value from `["foo", "bar"]`'), )); diff --git a/tests/feature/Rules/ContainsTest.php b/tests/feature/Rules/ContainsTest.php index 4306b8f1..d0f733c4 100644 --- a/tests/feature/Rules/ContainsTest.php +++ b/tests/feature/Rules/ContainsTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::contains('foo')->assert('bar'), - fn(string $message) => expect($message)->toBe('"bar" must contain "foo"') + fn(string $message) => expect($message)->toBe('"bar" must contain "foo"'), )); test('Scenario #2', catchMessage( fn() => v::not(v::contains('foo'))->assert('fool'), - fn(string $message) => expect($message)->toBe('"fool" must not contain "foo"') + fn(string $message) => expect($message)->toBe('"fool" must not contain "foo"'), )); test('Scenario #3', catchFullMessage( fn() => v::contains('foo')->assert(['bar']), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `["bar"]` must contain "foo"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `["bar"]` must contain "foo"'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::contains('foo', true))->assert(['bar', 'foo']), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `["bar", "foo"]` must not contain "foo"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `["bar", "foo"]` must not contain "foo"'), )); diff --git a/tests/feature/Rules/CountableTest.php b/tests/feature/Rules/CountableTest.php index 5908be5b..d3f84f62 100644 --- a/tests/feature/Rules/CountableTest.php +++ b/tests/feature/Rules/CountableTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::countable()->assert(1.0), - fn(string $message) => expect($message)->toBe('1.0 must be a countable value') + fn(string $message) => expect($message)->toBe('1.0 must be a countable value'), )); test('Scenario #2', catchMessage( fn() => v::not(v::countable())->assert([]), - fn(string $message) => expect($message)->toBe('`[]` must not be a countable value') + fn(string $message) => expect($message)->toBe('`[]` must not be a countable value'), )); test('Scenario #3', catchFullMessage( fn() => v::countable()->assert('Not countable!'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "Not countable!" must be a countable value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "Not countable!" must be a countable value'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::countable())->assert(new ArrayObject()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `ArrayObject { getArrayCopy() => [] }` must not be a countable value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `ArrayObject { getArrayCopy() => [] }` must not be a countable value'), )); diff --git a/tests/feature/Rules/CountryCodeTest.php b/tests/feature/Rules/CountryCodeTest.php index 950c9804..7cc2d5b7 100644 --- a/tests/feature/Rules/CountryCodeTest.php +++ b/tests/feature/Rules/CountryCodeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::countryCode()->assert('1'), - fn(string $message) => expect($message)->toBe('"1" must be a valid country code') + fn(string $message) => expect($message)->toBe('"1" must be a valid country code'), )); test('Scenario #2', catchMessage( fn() => v::not(v::countryCode())->assert('BR'), - fn(string $message) => expect($message)->toBe('"BR" must not be a valid country code') + fn(string $message) => expect($message)->toBe('"BR" must not be a valid country code'), )); test('Scenario #3', catchFullMessage( fn() => v::countryCode()->assert('1'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1" must be a valid country code') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1" must be a valid country code'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::countryCode())->assert('BR'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "BR" must not be a valid country code') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "BR" must not be a valid country code'), )); diff --git a/tests/feature/Rules/CpfTest.php b/tests/feature/Rules/CpfTest.php index b5f22869..0bf4fc3e 100644 --- a/tests/feature/Rules/CpfTest.php +++ b/tests/feature/Rules/CpfTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::cpf()->assert('this thing'), - fn(string $message) => expect($message)->toBe('"this thing" must be a valid CPF number') + fn(string $message) => expect($message)->toBe('"this thing" must be a valid CPF number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::cpf())->assert('276.865.775-11'), - fn(string $message) => expect($message)->toBe('"276.865.775-11" must not be a valid CPF number') + fn(string $message) => expect($message)->toBe('"276.865.775-11" must not be a valid CPF number'), )); test('Scenario #3', catchFullMessage( fn() => v::cpf()->assert('your mother'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "your mother" must be a valid CPF number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "your mother" must be a valid CPF number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::cpf())->assert('61836182848'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "61836182848" must not be a valid CPF number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "61836182848" must not be a valid CPF number'), )); diff --git a/tests/feature/Rules/CreditCardTest.php b/tests/feature/Rules/CreditCardTest.php index 15394153..fef9639c 100644 --- a/tests/feature/Rules/CreditCardTest.php +++ b/tests/feature/Rules/CreditCardTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::creditCard('Discover')->assert(3566002020360505), - fn(string $message) => expect($message)->toBe('3566002020360505 must be a valid Discover credit card number') + fn(string $message) => expect($message)->toBe('3566002020360505 must be a valid Discover credit card number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::creditCard('Visa'))->assert(4024007153361885), - fn(string $message) => expect($message)->toBe('4024007153361885 must not be a valid Visa credit card number') + fn(string $message) => expect($message)->toBe('4024007153361885 must not be a valid Visa credit card number'), )); test('Scenario #3', catchFullMessage( fn() => v::creditCard('MasterCard')->assert(3566002020360505), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 3566002020360505 must be a valid MasterCard credit card number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 3566002020360505 must be a valid MasterCard credit card number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::creditCard())->assert(5555444433331111), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 5555444433331111 must not be a valid credit card number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 5555444433331111 must not be a valid credit card number'), )); diff --git a/tests/feature/Rules/CurrencyCodeTest.php b/tests/feature/Rules/CurrencyCodeTest.php index 055cb986..d6ba5f06 100644 --- a/tests/feature/Rules/CurrencyCodeTest.php +++ b/tests/feature/Rules/CurrencyCodeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::currencyCode()->assert('batman'), - fn(string $message) => expect($message)->toBe('"batman" must be a valid currency code') + fn(string $message) => expect($message)->toBe('"batman" must be a valid currency code'), )); test('Scenario #2', catchMessage( fn() => v::not(v::currencyCode())->assert('BRL'), - fn(string $message) => expect($message)->toBe('"BRL" must not be a valid currency code') + fn(string $message) => expect($message)->toBe('"BRL" must not be a valid currency code'), )); test('Scenario #3', catchFullMessage( fn() => v::currencyCode()->assert('ppz'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "ppz" must be a valid currency code') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "ppz" must be a valid currency code'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::currencyCode())->assert('GBP'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "GBP" must not be a valid currency code') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "GBP" must not be a valid currency code'), )); diff --git a/tests/feature/Rules/DateTest.php b/tests/feature/Rules/DateTest.php index 4e004b82..d0378b9e 100644 --- a/tests/feature/Rules/DateTest.php +++ b/tests/feature/Rules/DateTest.php @@ -11,20 +11,20 @@ date_default_timezone_set('UTC'); test('Scenario #1', catchMessage( fn() => v::date()->assert('2018-01-29T08:32:54+00:00'), - fn(string $message) => expect($message)->toBe('"2018-01-29T08:32:54+00:00" must be a valid date in the format "2005-12-30"') + fn(string $message) => expect($message)->toBe('"2018-01-29T08:32:54+00:00" must be a valid date in the format "2005-12-30"'), )); test('Scenario #2', catchMessage( fn() => v::not(v::date())->assert('2018-01-29'), - fn(string $message) => expect($message)->toBe('"2018-01-29" must not be a valid date in the format "2005-12-30"') + fn(string $message) => expect($message)->toBe('"2018-01-29" must not be a valid date in the format "2005-12-30"'), )); test('Scenario #3', catchFullMessage( fn() => v::date()->assert('2018-01-29T08:32:54+00:00'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "2018-01-29T08:32:54+00:00" must be a valid date in the format "2005-12-30"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "2018-01-29T08:32:54+00:00" must be a valid date in the format "2005-12-30"'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::date('d/m/Y'))->assert('29/01/2018'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "29/01/2018" must not be a valid date in the format "30/12/2005"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "29/01/2018" must not be a valid date in the format "30/12/2005"'), )); diff --git a/tests/feature/Rules/DateTimeDiffTest.php b/tests/feature/Rules/DateTimeDiffTest.php index 1ccc1974..5be75bae 100644 --- a/tests/feature/Rules/DateTimeDiffTest.php +++ b/tests/feature/Rules/DateTimeDiffTest.php @@ -12,7 +12,7 @@ test('With $type = "years"', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The number of years between now and "1 year ago" must be equal to 2') ->and($fullMessage)->toBe('- The number of years between now and "1 year ago" must be equal to 2') - ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of years between now and "1 year ago" must be equal to 2']) + ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of years between now and "1 year ago" must be equal to 2']), )); test('With $type = "months"', catchAll( @@ -20,7 +20,7 @@ test('With $type = "months"', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The number of months between now and "2 months ago" must be equal to 3') ->and($fullMessage)->toBe('- The number of months between now and "2 months ago" must be equal to 3') - ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of months between now and "2 months ago" must be equal to 3']) + ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of months between now and "2 months ago" must be equal to 3']), )); test('With $type = "days"', catchAll( @@ -28,7 +28,7 @@ test('With $type = "days"', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The number of days between now and "3 days ago" must be equal to 4') ->and($fullMessage)->toBe('- The number of days between now and "3 days ago" must be equal to 4') - ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of days between now and "3 days ago" must be equal to 4']) + ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of days between now and "3 days ago" must be equal to 4']), )); test('With $type = "hours"', catchAll( @@ -36,7 +36,7 @@ test('With $type = "hours"', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The number of hours between now and "4 hours ago" must be equal to 5') ->and($fullMessage)->toBe('- The number of hours between now and "4 hours ago" must be equal to 5') - ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of hours between now and "4 hours ago" must be equal to 5']) + ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of hours between now and "4 hours ago" must be equal to 5']), )); test('With $type = "minutes"', catchAll( @@ -44,7 +44,7 @@ test('With $type = "minutes"', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The number of minutes between now and "5 minutes ago" must be equal to 6') ->and($fullMessage)->toBe('- The number of minutes between now and "5 minutes ago" must be equal to 6') - ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of minutes between now and "5 minutes ago" must be equal to 6']) + ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of minutes between now and "5 minutes ago" must be equal to 6']), )); test('With $type = "microseconds"', catchAll( @@ -52,7 +52,7 @@ test('With $type = "microseconds"', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The number of microseconds between now and "6 microseconds ago" must be equal to 7') ->and($fullMessage)->toBe('- The number of microseconds between now and "6 microseconds ago" must be equal to 7') - ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of microseconds between now and "6 microseconds ago" must be equal to 7']) + ->and($messages)->toBe(['dateTimeDiffEquals' => 'The number of microseconds between now and "6 microseconds ago" must be equal to 7']), )); test('With custom $format', catchAll( @@ -67,14 +67,14 @@ test('With input in non-parseable date', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('For comparison with now, "not a date" must be a valid datetime') ->and($fullMessage)->toBe('- For comparison with now, "not a date" must be a valid datetime') - ->and($messages)->toBe(['dateTimeDiffEquals' => 'For comparison with now, "not a date" must be a valid datetime']) + ->and($messages)->toBe(['dateTimeDiffEquals' => 'For comparison with now, "not a date" must be a valid datetime']), )); test('With input in incorrect $format', catchAll( fn() => v::dateTimeDiff('years', v::equals(2), 'Y-m-d')->assert('1 year ago'), fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toMatch('/For comparison with \d+-\d+-\d+, "1 year ago" must be a valid datetime in the format \d+-\d+-\d+/') - ->and($fullMessage)->toMatch('/- For comparison with \d+-\d+-\d+, "1 year ago" must be a valid datetime in the format \d+-\d+-\d+/') + ->and($fullMessage)->toMatch('/- For comparison with \d+-\d+-\d+, "1 year ago" must be a valid datetime in the format \d+-\d+-\d+/'), )); test('With custom $now', catchAll( @@ -89,7 +89,7 @@ test('With custom template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Custom template') ->and($fullMessage)->toBe('- Custom template') - ->and($messages)->toBe(['equals' => 'Custom template']) + ->and($messages)->toBe(['equals' => 'Custom template']), )); test('Wrapped by "not"', catchAll( @@ -97,7 +97,7 @@ test('Wrapped by "not"', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The number of years between now and "7 year ago" must not be less than 8') ->and($fullMessage)->toBe('- The number of years between now and "7 year ago" must not be less than 8') - ->and($messages)->toBe(['notDateTimeDiffLessThan' => 'The number of years between now and "7 year ago" must not be less than 8']) + ->and($messages)->toBe(['notDateTimeDiffLessThan' => 'The number of years between now and "7 year ago" must not be less than 8']), )); test('Wrapping "not"', catchAll( @@ -105,7 +105,7 @@ test('Wrapping "not"', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The number of years between now and "8 year ago" must not be less than 9') ->and($fullMessage)->toBe('- The number of years between now and "8 year ago" must not be less than 9') - ->and($messages)->toBe(['dateTimeDiffNotLessThan' => 'The number of years between now and "8 year ago" must not be less than 9']) + ->and($messages)->toBe(['dateTimeDiffNotLessThan' => 'The number of years between now and "8 year ago" must not be less than 9']), )); test('Wrapped with custom template', catchAll( @@ -113,7 +113,7 @@ test('Wrapped with custom template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped with custom template') ->and($fullMessage)->toBe('- Wrapped with custom template') - ->and($messages)->toBe(['equals' => 'Wrapped with custom template']) + ->and($messages)->toBe(['equals' => 'Wrapped with custom template']), )); test('Wrapper with custom template', catchAll( @@ -121,7 +121,7 @@ test('Wrapper with custom template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper with custom template') ->and($fullMessage)->toBe('- Wrapper with custom template') - ->and($messages)->toBe(['dateTimeDiffEquals' => 'Wrapper with custom template']) + ->and($messages)->toBe(['dateTimeDiffEquals' => 'Wrapper with custom template']), )); test('Without adjacent result', catchAll( @@ -137,7 +137,7 @@ test('Without adjacent result', catchAll( '__root__' => '"1 year ago" must pass all the rules', 'dateTimeDiffPrimeNumber' => 'The number of years between now and "1 year ago" must be a prime number', 'dateTimeDiffBetween' => 'The number of years between now and "1 year ago" must be between 2 and 5', - ]) + ]), )); test('Without adjacent result with templates', catchAll( @@ -158,5 +158,5 @@ test('Without adjacent result with templates', catchAll( '__root__' => '"1 year ago" must pass all the rules', 'dateTimeDiffPrimeNumber' => 'The number of years between now and "1 year ago" must be a prime number', 'dateTimeDiffBetween' => 'The number of years between now and "1 year ago" must be between 2 and 5', - ]) + ]), )); diff --git a/tests/feature/Rules/DateTimeTest.php b/tests/feature/Rules/DateTimeTest.php index b1828d50..89a096a6 100644 --- a/tests/feature/Rules/DateTimeTest.php +++ b/tests/feature/Rules/DateTimeTest.php @@ -11,40 +11,40 @@ date_default_timezone_set('UTC'); test('Scenario #1', catchMessage( fn() => v::dateTime()->assert('FooBarBazz'), - fn(string $message) => expect($message)->toBe('"FooBarBazz" must be a valid date/time') + fn(string $message) => expect($message)->toBe('"FooBarBazz" must be a valid date/time'), )); test('Scenario #2', catchMessage( fn() => v::dateTime('c')->assert('06-12-1995'), - fn(string $message) => expect($message)->toBe('"06-12-1995" must be a valid date/time in the format "2005-12-30T01:02:03+00:00"') + fn(string $message) => expect($message)->toBe('"06-12-1995" must be a valid date/time in the format "2005-12-30T01:02:03+00:00"'), )); test('Scenario #3', catchFullMessage( fn() => v::dateTime()->assert('QuxQuuxx'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "QuxQuuxx" must be a valid date/time') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "QuxQuuxx" must be a valid date/time'), )); test('Scenario #4', catchFullMessage( fn() => v::dateTime('r')->assert(2018013030), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 2018013030 must be a valid date/time in the format "Fri, 30 Dec 2005 01:02:03 +0000"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 2018013030 must be a valid date/time in the format "Fri, 30 Dec 2005 01:02:03 +0000"'), )); test('Scenario #5', catchMessage( fn() => v::not(v::dateTime())->assert('4 days ago'), - fn(string $message) => expect($message)->toBe('"4 days ago" must not be a valid date/time') + fn(string $message) => expect($message)->toBe('"4 days ago" must not be a valid date/time'), )); test('Scenario #6', catchMessage( fn() => v::not(v::dateTime('Y-m-d'))->assert('1988-09-09'), - fn(string $message) => expect($message)->toBe('"1988-09-09" must not be a valid date/time in the format "2005-12-30"') + fn(string $message) => expect($message)->toBe('"1988-09-09" must not be a valid date/time in the format "2005-12-30"'), )); test('Scenario #7', catchFullMessage( fn() => v::not(v::dateTime())->assert('+3 weeks'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "+3 weeks" must not be a valid date/time') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "+3 weeks" must not be a valid date/time'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::dateTime('d/m/y'))->assert('23/07/99'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "23/07/99" must not be a valid date/time in the format "30/12/05"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "23/07/99" must not be a valid date/time in the format "30/12/05"'), )); diff --git a/tests/feature/Rules/DecimalTest.php b/tests/feature/Rules/DecimalTest.php index 637a97db..9c3ec7d1 100644 --- a/tests/feature/Rules/DecimalTest.php +++ b/tests/feature/Rules/DecimalTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::decimal(3)->assert(0.1234), - fn(string $message) => expect($message)->toBe('0.1234 must have 3 decimals') + fn(string $message) => expect($message)->toBe('0.1234 must have 3 decimals'), )); test('Scenario #2', catchFullMessage( fn() => v::decimal(2)->assert(0.123), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 0.123 must have 2 decimals') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 0.123 must have 2 decimals'), )); test('Scenario #3', catchMessage( fn() => v::not(v::decimal(5))->assert(0.12345), - fn(string $message) => expect($message)->toBe('0.12345 must not have 5 decimals') + fn(string $message) => expect($message)->toBe('0.12345 must not have 5 decimals'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::decimal(2))->assert(0.34), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 0.34 must not have 2 decimals') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 0.34 must not have 2 decimals'), )); diff --git a/tests/feature/Rules/DigitTest.php b/tests/feature/Rules/DigitTest.php index cbb2c1c7..bcba941b 100644 --- a/tests/feature/Rules/DigitTest.php +++ b/tests/feature/Rules/DigitTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::digit()->assert('abc'), - fn(string $message) => expect($message)->toBe('"abc" must contain only digits (0-9)') + fn(string $message) => expect($message)->toBe('"abc" must contain only digits (0-9)'), )); test('Scenario #2', catchMessage( fn() => v::digit('-')->assert('a-b'), - fn(string $message) => expect($message)->toBe('"a-b" must contain only digits (0-9) and "-"') + fn(string $message) => expect($message)->toBe('"a-b" must contain only digits (0-9) and "-"'), )); test('Scenario #3', catchMessage( fn() => v::not(v::digit())->assert('123'), - fn(string $message) => expect($message)->toBe('"123" must not contain digits (0-9)') + fn(string $message) => expect($message)->toBe('"123" must not contain digits (0-9)'), )); test('Scenario #4', catchMessage( fn() => v::not(v::digit('-'))->assert('1-3'), - fn(string $message) => expect($message)->toBe('"1-3" must not contain digits (0-9) and "-"') + fn(string $message) => expect($message)->toBe('"1-3" must not contain digits (0-9) and "-"'), )); test('Scenario #5', catchFullMessage( fn() => v::digit()->assert('abc'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "abc" must contain only digits (0-9)') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "abc" must contain only digits (0-9)'), )); test('Scenario #6', catchFullMessage( fn() => v::digit('-')->assert('a-b'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "a-b" must contain only digits (0-9) and "-"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "a-b" must contain only digits (0-9) and "-"'), )); test('Scenario #7', catchFullMessage( fn() => v::not(v::digit())->assert('123'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "123" must not contain digits (0-9)') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "123" must not contain digits (0-9)'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::digit('-'))->assert('1-3'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1-3" must not contain digits (0-9) and "-"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1-3" must not contain digits (0-9) and "-"'), )); diff --git a/tests/feature/Rules/DirectoryTest.php b/tests/feature/Rules/DirectoryTest.php index 48816d6b..f09ef254 100644 --- a/tests/feature/Rules/DirectoryTest.php +++ b/tests/feature/Rules/DirectoryTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::directory()->assert('batman'), - fn(string $message) => expect($message)->toBe('"batman" must be a directory') + fn(string $message) => expect($message)->toBe('"batman" must be a directory'), )); test('Scenario #2', catchMessage( fn() => v::not(v::directory())->assert(dirname('/etc/')), - fn(string $message) => expect($message)->toBe('"/" must not be a directory') + fn(string $message) => expect($message)->toBe('"/" must not be a directory'), )); test('Scenario #3', catchFullMessage( fn() => v::directory()->assert('ppz'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "ppz" must be a directory') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "ppz" must be a directory'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::directory())->assert(dirname('/etc/')), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "/" must not be a directory') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "/" must not be a directory'), )); diff --git a/tests/feature/Rules/DomainTest.php b/tests/feature/Rules/DomainTest.php index bd3a6ed0..b728df42 100644 --- a/tests/feature/Rules/DomainTest.php +++ b/tests/feature/Rules/DomainTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::domain()->assert('batman'), - fn(string $message) => expect($message)->toBe('"batman" must be a valid domain') + fn(string $message) => expect($message)->toBe('"batman" must be a valid domain'), )); test('Scenario #2', catchMessage( fn() => v::not(v::domain())->assert('r--w.com'), - fn(string $message) => expect($message)->toBe('"r--w.com" must not be a valid domain') + fn(string $message) => expect($message)->toBe('"r--w.com" must not be a valid domain'), )); test('Scenario #3', catchFullMessage( fn() => v::domain()->assert('p-éz-.kk'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "p-éz-.kk" must be a valid domain') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "p-éz-.kk" must be a valid domain'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::domain())->assert('github.com'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "github.com" must not be a valid domain') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "github.com" must not be a valid domain'), )); diff --git a/tests/feature/Rules/EachTest.php b/tests/feature/Rules/EachTest.php index a540c0fa..21d29d5b 100644 --- a/tests/feature/Rules/EachTest.php +++ b/tests/feature/Rules/EachTest.php @@ -9,7 +9,7 @@ declare(strict_types=1); test('Non-iterable', catchAll( fn() => v::each(v::intType())->assert(null), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`null` must be iterable') ->and($fullMessage)->toBe('- `null` must be iterable') ->and($messages)->toBe(['each' => '`null` must be iterable']), @@ -17,7 +17,7 @@ test('Non-iterable', catchAll( test('Empty', catchAll( fn() => v::each(v::intType())->assert([]), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`[]` must not be empty') ->and($fullMessage)->toBe('- `[]` must not be empty') ->and($messages)->toBe(['each' => '`[]` must not be empty']), @@ -25,7 +25,7 @@ test('Empty', catchAll( test('Default', catchAll( fn() => v::each(v::intType())->assert(['a', 'b', 'c']), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.0` must be an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Each item in `["a", "b", "c"]` must be valid @@ -43,7 +43,7 @@ test('Default', catchAll( test('Inverted', catchAll( fn() => v::not(v::each(v::intType()))->assert([1, 2, 3]), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.0` must not be an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Each item in `[1, 2, 3]` must be invalid @@ -61,7 +61,7 @@ test('Inverted', catchAll( test('With name, non-iterable', catchAll( fn() => v::each(v::intType()->setName('Wrapped'))->assert(null), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must be iterable') ->and($fullMessage)->toBe('- Wrapped must be iterable') ->and($messages)->toBe(['each' => 'Wrapped must be iterable']), @@ -69,7 +69,7 @@ test('With name, non-iterable', catchAll( test('With name, empty', catchAll( fn() => v::each(v::intType()->setName('Wrapped'))->assert([]), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must not be empty') ->and($fullMessage)->toBe('- Wrapped must not be empty') ->and($messages)->toBe(['each' => 'Wrapped must not be empty']), @@ -77,7 +77,7 @@ test('With name, empty', catchAll( test('With name, default', catchAll( fn() => v::each(v::intType()->setName('Wrapped'))->setName('Wrapper')->assert(['a', 'b', 'c']), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must be an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Each item in Wrapped must be valid @@ -95,7 +95,7 @@ test('With name, default', catchAll( test('With name, inverted', catchAll( fn() => v::not(v::each(v::intType()->setName('Wrapped'))->setName('Wrapper'))->setName('Not')->assert([1, 2, 3]), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must not be an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Each item in Wrapped must be invalid @@ -113,7 +113,7 @@ test('With name, inverted', catchAll( test('With wrapper name, default', catchAll( fn() => v::each(v::intType())->setName('Wrapper')->assert(['a', 'b', 'c']), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.0` must be an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Each item in Wrapper must be valid @@ -131,7 +131,7 @@ test('With wrapper name, default', catchAll( test('With wrapper name, inverted', catchAll( fn() => v::not(v::each(v::intType())->setName('Wrapper'))->setName('Not')->assert([1, 2, 3]), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.0` must not be an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Each item in Wrapper must be invalid @@ -149,7 +149,7 @@ test('With wrapper name, inverted', catchAll( test('With Not name, inverted', catchAll( fn() => v::not(v::each(v::intType()))->setName('Not')->assert([1, 2, 3]), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.0` must not be an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Each item in Not must be invalid @@ -167,7 +167,7 @@ test('With Not name, inverted', catchAll( test('With template, non-iterable', catchAll( fn() => v::each(v::intType())->setTemplate('You should have passed an iterable')->assert(null), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('You should have passed an iterable') ->and($fullMessage)->toBe('- You should have passed an iterable') ->and($messages)->toBe(['each' => 'You should have passed an iterable']), @@ -176,7 +176,7 @@ test('With template, non-iterable', catchAll( test('With template, empty', catchAll( fn() => v::each(v::intType())->setTemplate('You should have passed an non-empty') ->assert([]), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('You should have passed an non-empty') ->and($fullMessage)->toBe('- You should have passed an non-empty') ->and($messages)->toBe(['each' => 'You should have passed an non-empty']), @@ -186,7 +186,7 @@ test('With template, default', catchAll( fn() => v::each(v::intType()) ->setTemplate('All items should have been integers') ->assert(['a', 'b', 'c']), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('All items should have been integers') ->and($fullMessage)->toBe('- All items should have been integers') ->and($messages)->toBe(['each' => 'All items should have been integers']), @@ -196,7 +196,7 @@ test('with template, inverted', catchAll( fn() => v::not(v::each(v::intType())) ->setTemplate('All items should not have been integers') ->assert([1, 2, 3]), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('All items should not have been integers') ->and($fullMessage)->toBe('- All items should not have been integers') ->and($messages)->toBe(['notEach' => 'All items should not have been integers']), @@ -213,7 +213,7 @@ test('With array template, default', catchAll( ], ]) ->assert(['a', 'b', 'c']), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('First item should have been an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Here a sequence of items that did not pass the validation @@ -241,7 +241,7 @@ test('With array template and name, default', catchAll( ], ]) ->assert(['a', 'b', 'c']), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('First item should have been an integer') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Here a sequence of items that did not pass the validation @@ -259,7 +259,7 @@ test('With array template and name, default', catchAll( test('Chained wrapped rule', catchAll( fn() => v::each(v::between(5, 7)->odd())->assert([2, 4]), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.0` must be between 5 and 7') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Each item in `[2, 4]` must be valid @@ -287,7 +287,7 @@ test('Chained wrapped rule', catchAll( test('Multiple nested rules', catchAll( fn() => v::each(v::arrayType()->key('my_int', v::intType()->odd()))->assert([['not_int' => 'wrong'], ['my_int' => 2], 'not an array']), - fn (string $message, string $fullMessage, array $messages) => expect() + fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.0.my_int` must be present') ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - Each item in `[["not_int": "wrong"], ["my_int": 2], "not an array"]` must be valid diff --git a/tests/feature/Rules/EmailTest.php b/tests/feature/Rules/EmailTest.php index 2f431f08..ffb7b11d 100644 --- a/tests/feature/Rules/EmailTest.php +++ b/tests/feature/Rules/EmailTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::email()->assert('batman'), - fn(string $message) => expect($message)->toBe('"batman" must be a valid email address') + fn(string $message) => expect($message)->toBe('"batman" must be a valid email address'), )); test('Scenario #2', catchMessage( fn() => v::not(v::email())->assert('bruce.wayne@gothancity.com'), - fn(string $message) => expect($message)->toBe('"bruce.wayne@gothancity.com" must not be an email address') + fn(string $message) => expect($message)->toBe('"bruce.wayne@gothancity.com" must not be an email address'), )); test('Scenario #3', catchFullMessage( fn() => v::email()->assert('bruce wayne'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "bruce wayne" must be a valid email address') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "bruce wayne" must be a valid email address'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::email())->assert('iambatman@gothancity.com'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "iambatman@gothancity.com" must not be an email address') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "iambatman@gothancity.com" must not be an email address'), )); diff --git a/tests/feature/Rules/EndsWithTest.php b/tests/feature/Rules/EndsWithTest.php index 87d040b0..1c765ea4 100644 --- a/tests/feature/Rules/EndsWithTest.php +++ b/tests/feature/Rules/EndsWithTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::endsWith('foo')->assert('bar'), - fn(string $message) => expect($message)->toBe('"bar" must end with "foo"') + fn(string $message) => expect($message)->toBe('"bar" must end with "foo"'), )); test('Scenario #2', catchMessage( fn() => v::not(v::endsWith('foo'))->assert(['bar', 'foo']), - fn(string $message) => expect($message)->toBe('`["bar", "foo"]` must not end with "foo"') + fn(string $message) => expect($message)->toBe('`["bar", "foo"]` must not end with "foo"'), )); test('Scenario #3', catchFullMessage( fn() => v::endsWith('foo')->assert(''), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must end with "foo"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must end with "foo"'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::endsWith('foo'))->assert(['bar', 'foo']), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `["bar", "foo"]` must not end with "foo"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `["bar", "foo"]` must not end with "foo"'), )); diff --git a/tests/feature/Rules/EqualsTest.php b/tests/feature/Rules/EqualsTest.php index 14b5fd96..491f84d2 100644 --- a/tests/feature/Rules/EqualsTest.php +++ b/tests/feature/Rules/EqualsTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::equals(123)->assert(321), - fn(string $message) => expect($message)->toBe('321 must be equal to 123') + fn(string $message) => expect($message)->toBe('321 must be equal to 123'), )); test('Scenario #2', catchMessage( fn() => v::not(v::equals(321))->assert(321), - fn(string $message) => expect($message)->toBe('321 must not be equal to 321') + fn(string $message) => expect($message)->toBe('321 must not be equal to 321'), )); test('Scenario #3', catchFullMessage( fn() => v::equals(123)->assert(321), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 321 must be equal to 123') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 321 must be equal to 123'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::equals(321))->assert(321), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 321 must not be equal to 321') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 321 must not be equal to 321'), )); diff --git a/tests/feature/Rules/EquivalentTest.php b/tests/feature/Rules/EquivalentTest.php index 7d121a55..77ed57a4 100644 --- a/tests/feature/Rules/EquivalentTest.php +++ b/tests/feature/Rules/EquivalentTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::equivalent(true)->assert(false), - fn(string $message) => expect($message)->toBe('`false` must be equivalent to `true`') + fn(string $message) => expect($message)->toBe('`false` must be equivalent to `true`'), )); test('Scenario #2', catchMessage( fn() => v::not(v::equivalent('Something'))->assert('someThing'), - fn(string $message) => expect($message)->toBe('"someThing" must not be equivalent to "Something"') + fn(string $message) => expect($message)->toBe('"someThing" must not be equivalent to "Something"'), )); test('Scenario #3', catchFullMessage( fn() => v::equivalent(123)->assert('true'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "true" must be equivalent to 123') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "true" must be equivalent to 123'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::equivalent(true))->assert(1), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 1 must not be equivalent to `true`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 1 must not be equivalent to `true`'), )); diff --git a/tests/feature/Rules/EvenTest.php b/tests/feature/Rules/EvenTest.php index c6a7732e..3bace5c4 100644 --- a/tests/feature/Rules/EvenTest.php +++ b/tests/feature/Rules/EvenTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::even()->assert(-1), - fn(string $message) => expect($message)->toBe('-1 must be an even number') + fn(string $message) => expect($message)->toBe('-1 must be an even number'), )); test('Scenario #2', catchFullMessage( fn() => v::even()->assert(5), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 5 must be an even number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 5 must be an even number'), )); test('Scenario #3', catchMessage( fn() => v::not(v::even())->assert(6), - fn(string $message) => expect($message)->toBe('6 must be an odd number') + fn(string $message) => expect($message)->toBe('6 must be an odd number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::even())->assert(8), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 8 must be an odd number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 8 must be an odd number'), )); diff --git a/tests/feature/Rules/ExecutableTest.php b/tests/feature/Rules/ExecutableTest.php index cea38f6d..1c4b52c1 100644 --- a/tests/feature/Rules/ExecutableTest.php +++ b/tests/feature/Rules/ExecutableTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::executable()->assert('bar'), - fn(string $message) => expect($message)->toBe('"bar" must be an executable file') + fn(string $message) => expect($message)->toBe('"bar" must be an executable file'), )); test('Scenario #2', catchMessage( fn() => v::not(v::executable())->assert('tests/fixtures/executable'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/executable" must not be an executable file') + fn(string $message) => expect($message)->toBe('"tests/fixtures/executable" must not be an executable file'), )); test('Scenario #3', catchFullMessage( fn() => v::executable()->assert('bar'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "bar" must be an executable file') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "bar" must be an executable file'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::executable())->assert('tests/fixtures/executable'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/executable" must not be an executable file') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/executable" must not be an executable file'), )); diff --git a/tests/feature/Rules/ExistsTest.php b/tests/feature/Rules/ExistsTest.php index e685806d..9cde9dc0 100644 --- a/tests/feature/Rules/ExistsTest.php +++ b/tests/feature/Rules/ExistsTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::exists()->assert('/path/of/a/non-existent/file'), - fn(string $message) => expect($message)->toBe('"/path/of/a/non-existent/file" must be an existing file') + fn(string $message) => expect($message)->toBe('"/path/of/a/non-existent/file" must be an existing file'), )); test('Scenario #2', catchMessage( fn() => v::not(v::exists())->assert('tests/fixtures/valid-image.gif'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.gif" must not be an existing file') + fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.gif" must not be an existing file'), )); test('Scenario #3', catchFullMessage( fn() => v::exists()->assert('/path/of/a/non-existent/file'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "/path/of/a/non-existent/file" must be an existing file') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "/path/of/a/non-existent/file" must be an existing file'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::exists())->assert('tests/fixtures/valid-image.png'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/valid-image.png" must not be an existing file') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/valid-image.png" must not be an existing file'), )); diff --git a/tests/feature/Rules/ExtensionTest.php b/tests/feature/Rules/ExtensionTest.php index 313a66d6..e078084e 100644 --- a/tests/feature/Rules/ExtensionTest.php +++ b/tests/feature/Rules/ExtensionTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::extension('png')->assert('filename.txt'), - fn(string $message) => expect($message)->toBe('"filename.txt" must have "png" extension') + fn(string $message) => expect($message)->toBe('"filename.txt" must have "png" extension'), )); test('Scenario #2', catchMessage( fn() => v::not(v::extension('gif'))->assert('filename.gif'), - fn(string $message) => expect($message)->toBe('"filename.gif" must not have "gif" extension') + fn(string $message) => expect($message)->toBe('"filename.gif" must not have "gif" extension'), )); test('Scenario #3', catchFullMessage( fn() => v::extension('mp3')->assert('filename.wav'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "filename.wav" must have "mp3" extension') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "filename.wav" must have "mp3" extension'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::extension('png'))->assert('tests/fixtures/invalid-image.png'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/invalid-image.png" must not have "png" extension') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/invalid-image.png" must not have "png" extension'), )); diff --git a/tests/feature/Rules/FactorTest.php b/tests/feature/Rules/FactorTest.php index 55470414..7d749bce 100644 --- a/tests/feature/Rules/FactorTest.php +++ b/tests/feature/Rules/FactorTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::factor(3)->assert(2), - fn(string $message) => expect($message)->toBe('2 must be a factor of 3') + fn(string $message) => expect($message)->toBe('2 must be a factor of 3'), )); test('Scenario #2', catchMessage( fn() => v::not(v::factor(0))->assert(300), - fn(string $message) => expect($message)->toBe('300 must not be a factor of 0') + fn(string $message) => expect($message)->toBe('300 must not be a factor of 0'), )); test('Scenario #3', catchFullMessage( fn() => v::factor(5)->assert(3), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 3 must be a factor of 5') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 3 must be a factor of 5'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::factor(6))->assert(1), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 1 must not be a factor of 6') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 1 must not be a factor of 6'), )); diff --git a/tests/feature/Rules/FalseValTest.php b/tests/feature/Rules/FalseValTest.php index 07493e19..a1007cdb 100644 --- a/tests/feature/Rules/FalseValTest.php +++ b/tests/feature/Rules/FalseValTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::falseVal()->assert(true), - fn(string $message) => expect($message)->toBe('`true` must evaluate to `false`') + fn(string $message) => expect($message)->toBe('`true` must evaluate to `false`'), )); test('Scenario #2', catchMessage( fn() => v::not(v::falseVal())->assert('false'), - fn(string $message) => expect($message)->toBe('"false" must not evaluate to `false`') + fn(string $message) => expect($message)->toBe('"false" must not evaluate to `false`'), )); test('Scenario #3', catchFullMessage( fn() => v::falseVal()->assert(1), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 1 must evaluate to `false`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 1 must evaluate to `false`'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::falseVal())->assert(0), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 0 must not evaluate to `false`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 0 must not evaluate to `false`'), )); diff --git a/tests/feature/Rules/FibonacciTest.php b/tests/feature/Rules/FibonacciTest.php index 573b709c..7b7db61a 100644 --- a/tests/feature/Rules/FibonacciTest.php +++ b/tests/feature/Rules/FibonacciTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::fibonacci()->assert(4), - fn(string $message) => expect($message)->toBe('4 must be a valid Fibonacci number') + fn(string $message) => expect($message)->toBe('4 must be a valid Fibonacci number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::fibonacci())->assert(5), - fn(string $message) => expect($message)->toBe('5 must not be a valid Fibonacci number') + fn(string $message) => expect($message)->toBe('5 must not be a valid Fibonacci number'), )); test('Scenario #3', catchFullMessage( fn() => v::fibonacci()->assert(16), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 16 must be a valid Fibonacci number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 16 must be a valid Fibonacci number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::fibonacci())->assert(21), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 21 must not be a valid Fibonacci number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 21 must not be a valid Fibonacci number'), )); diff --git a/tests/feature/Rules/FileTest.php b/tests/feature/Rules/FileTest.php index 643a684d..d3b82a9d 100644 --- a/tests/feature/Rules/FileTest.php +++ b/tests/feature/Rules/FileTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::file()->assert('tests/fixtures/non-existent.sh'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/non-existent.sh" must be a valid file') + fn(string $message) => expect($message)->toBe('"tests/fixtures/non-existent.sh" must be a valid file'), )); test('Scenario #2', catchMessage( fn() => v::not(v::file())->assert('tests/fixtures/valid-image.png'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.png" must be an invalid file') + fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.png" must be an invalid file'), )); test('Scenario #3', catchFullMessage( fn() => v::file()->assert('tests/fixtures/non-existent.sh'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/non-existent.sh" must be a valid file') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/non-existent.sh" must be a valid file'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::file())->assert('tests/fixtures/valid-image.png'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/valid-image.png" must be an invalid file') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/valid-image.png" must be an invalid file'), )); diff --git a/tests/feature/Rules/FilterVarTest.php b/tests/feature/Rules/FilterVarTest.php index 91f192a5..06d2e774 100644 --- a/tests/feature/Rules/FilterVarTest.php +++ b/tests/feature/Rules/FilterVarTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::filterVar(FILTER_VALIDATE_IP)->assert(42), - fn(string $message) => expect($message)->toBe('42 must be valid') + fn(string $message) => expect($message)->toBe('42 must be valid'), )); test('Scenario #2', catchMessage( fn() => v::not(v::filterVar(FILTER_VALIDATE_BOOLEAN))->assert('On'), - fn(string $message) => expect($message)->toBe('"On" must not be valid') + fn(string $message) => expect($message)->toBe('"On" must not be valid'), )); test('Scenario #3', catchFullMessage( fn() => v::filterVar(FILTER_VALIDATE_EMAIL)->assert(1.5), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 1.5 must be valid') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 1.5 must be valid'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::filterVar(FILTER_VALIDATE_FLOAT))->assert(1.0), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 1.0 must not be valid') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 1.0 must not be valid'), )); diff --git a/tests/feature/Rules/FiniteTest.php b/tests/feature/Rules/FiniteTest.php index 6941c501..0d69c44d 100644 --- a/tests/feature/Rules/FiniteTest.php +++ b/tests/feature/Rules/FiniteTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::finite()->assert(''), - fn(string $message) => expect($message)->toBe('"" must be a finite number') + fn(string $message) => expect($message)->toBe('"" must be a finite number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::finite())->assert(10), - fn(string $message) => expect($message)->toBe('10 must not be a finite number') + fn(string $message) => expect($message)->toBe('10 must not be a finite number'), )); test('Scenario #3', catchFullMessage( fn() => v::finite()->assert([12]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[12]` must be a finite number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[12]` must be a finite number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::finite())->assert('123456'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "123456" must not be a finite number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "123456" must not be a finite number'), )); diff --git a/tests/feature/Rules/FloatTypeTest.php b/tests/feature/Rules/FloatTypeTest.php index 988d2094..5cef9808 100644 --- a/tests/feature/Rules/FloatTypeTest.php +++ b/tests/feature/Rules/FloatTypeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::floatType()->assert('42.33'), - fn(string $message) => expect($message)->toBe('"42.33" must be float') + fn(string $message) => expect($message)->toBe('"42.33" must be float'), )); test('Scenario #2', catchMessage( fn() => v::not(v::floatType())->assert(INF), - fn(string $message) => expect($message)->toBe('`INF` must not be float') + fn(string $message) => expect($message)->toBe('`INF` must not be float'), )); test('Scenario #3', catchFullMessage( fn() => v::floatType()->assert(true), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must be float') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must be float'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::floatType())->assert(2.0), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 2.0 must not be float') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 2.0 must not be float'), )); diff --git a/tests/feature/Rules/FloatvalTest.php b/tests/feature/Rules/FloatvalTest.php index a8eb157e..d015b838 100644 --- a/tests/feature/Rules/FloatvalTest.php +++ b/tests/feature/Rules/FloatvalTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::floatVal()->assert('a'), - fn(string $message) => expect($message)->toBe('"a" must be a float value') + fn(string $message) => expect($message)->toBe('"a" must be a float value'), )); test('Scenario #2', catchMessage( fn() => v::not(v::floatVal())->assert(165.0), - fn(string $message) => expect($message)->toBe('165.0 must not be a float value') + fn(string $message) => expect($message)->toBe('165.0 must not be a float value'), )); test('Scenario #3', catchFullMessage( fn() => v::floatVal()->assert('a'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must be a float value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must be a float value'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::floatVal())->assert('165.7'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "165.7" must not be a float value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "165.7" must not be a float value'), )); diff --git a/tests/feature/Rules/GraphTest.php b/tests/feature/Rules/GraphTest.php index e1e0fb7d..a94a3439 100644 --- a/tests/feature/Rules/GraphTest.php +++ b/tests/feature/Rules/GraphTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::graph()->assert("foo\nbar"), - fn(string $message) => expect($message)->toBe('"foo\\nbar" must contain only graphical characters') + fn(string $message) => expect($message)->toBe('"foo\\nbar" must contain only graphical characters'), )); test('Scenario #2', catchMessage( fn() => v::graph('foo')->assert("foo\nbar"), - fn(string $message) => expect($message)->toBe('"foo\\nbar" must contain only graphical characters and "foo"') + fn(string $message) => expect($message)->toBe('"foo\\nbar" must contain only graphical characters and "foo"'), )); test('Scenario #3', catchMessage( fn() => v::not(v::graph())->assert('foobar'), - fn(string $message) => expect($message)->toBe('"foobar" must not contain graphical characters') + fn(string $message) => expect($message)->toBe('"foobar" must not contain graphical characters'), )); test('Scenario #4', catchMessage( fn() => v::not(v::graph("\n"))->assert("foo\nbar"), - fn(string $message) => expect($message)->toBe('"foo\\nbar" must not contain graphical characters or "\\n"') + fn(string $message) => expect($message)->toBe('"foo\\nbar" must not contain graphical characters or "\\n"'), )); test('Scenario #5', catchFullMessage( fn() => v::graph()->assert("foo\nbar"), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "foo\\nbar" must contain only graphical characters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "foo\\nbar" must contain only graphical characters'), )); test('Scenario #6', catchFullMessage( fn() => v::graph('foo')->assert("foo\nbar"), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "foo\\nbar" must contain only graphical characters and "foo"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "foo\\nbar" must contain only graphical characters and "foo"'), )); test('Scenario #7', catchFullMessage( fn() => v::not(v::graph())->assert('foobar'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "foobar" must not contain graphical characters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "foobar" must not contain graphical characters'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::graph("\n"))->assert("foo\nbar"), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "foo\\nbar" must not contain graphical characters or "\\n"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "foo\\nbar" must not contain graphical characters or "\\n"'), )); diff --git a/tests/feature/Rules/GreaterThanOrEqualTest.php b/tests/feature/Rules/GreaterThanOrEqualTest.php index d7f26010..bb571ce9 100644 --- a/tests/feature/Rules/GreaterThanOrEqualTest.php +++ b/tests/feature/Rules/GreaterThanOrEqualTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::greaterThanOrEqual(INF)->assert(10), - fn(string $message) => expect($message)->toBe('10 must be greater than or equal to `INF`') + fn(string $message) => expect($message)->toBe('10 must be greater than or equal to `INF`'), )); test('Scenario #2', catchMessage( fn() => v::not(v::greaterThanOrEqual(5))->assert(INF), - fn(string $message) => expect($message)->toBe('`INF` must be less than 5') + fn(string $message) => expect($message)->toBe('`INF` must be less than 5'), )); test('Scenario #3', catchFullMessage( fn() => v::greaterThanOrEqual('today')->assert('yesterday'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "yesterday" must be greater than or equal to "today"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "yesterday" must be greater than or equal to "today"'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::greaterThanOrEqual('a'))->assert('z'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "z" must be less than "a"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "z" must be less than "a"'), )); diff --git a/tests/feature/Rules/GreaterThanTest.php b/tests/feature/Rules/GreaterThanTest.php index cbecc5e3..bc42257c 100644 --- a/tests/feature/Rules/GreaterThanTest.php +++ b/tests/feature/Rules/GreaterThanTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::greaterThan(21)->assert(12), - fn(string $message) => expect($message)->toBe('12 must be greater than 21') + fn(string $message) => expect($message)->toBe('12 must be greater than 21'), )); test('Scenario #2', catchMessage( fn() => v::not(v::greaterThan('yesterday'))->assert('today'), - fn(string $message) => expect($message)->toBe('"today" must not be greater than "yesterday"') + fn(string $message) => expect($message)->toBe('"today" must not be greater than "yesterday"'), )); test('Scenario #3', catchFullMessage( fn() => v::greaterThan('2018-09-09')->assert('1988-09-09'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1988-09-09" must be greater than "2018-09-09"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1988-09-09" must be greater than "2018-09-09"'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::greaterThan('a'))->assert('ba'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "ba" must not be greater than "a"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "ba" must not be greater than "a"'), )); diff --git a/tests/feature/Rules/HetuTest.php b/tests/feature/Rules/HetuTest.php index 7d1b6d58..8656f8ec 100644 --- a/tests/feature/Rules/HetuTest.php +++ b/tests/feature/Rules/HetuTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"010106A901O" must be a valid Finnish personal identity code') ->and($fullMessage)->toBe('- "010106A901O" must be a valid Finnish personal identity code') - ->and($messages)->toBe(['hetu' => '"010106A901O" must be a valid Finnish personal identity code']) + ->and($messages)->toBe(['hetu' => '"010106A901O" must be a valid Finnish personal identity code']), )); test('Inverted', catchAll( @@ -20,7 +20,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"010106A9012" must not be a valid Finnish personal identity code') ->and($fullMessage)->toBe('- "010106A9012" must not be a valid Finnish personal identity code') - ->and($messages)->toBe(['notHetu' => '"010106A9012" must not be a valid Finnish personal identity code']) + ->and($messages)->toBe(['notHetu' => '"010106A9012" must not be a valid Finnish personal identity code']), )); test('With template', catchAll( @@ -28,7 +28,7 @@ test('With template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('That is not a HETU') ->and($fullMessage)->toBe('- That is not a HETU') - ->and($messages)->toBe(['hetu' => 'That is not a HETU']) + ->and($messages)->toBe(['hetu' => 'That is not a HETU']), )); test('With name', catchAll( @@ -36,5 +36,5 @@ test('With name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Hetu must be a valid Finnish personal identity code') ->and($fullMessage)->toBe('- Hetu must be a valid Finnish personal identity code') - ->and($messages)->toBe(['hetu' => 'Hetu must be a valid Finnish personal identity code']) + ->and($messages)->toBe(['hetu' => 'Hetu must be a valid Finnish personal identity code']), )); diff --git a/tests/feature/Rules/HexRgbColorTest.php b/tests/feature/Rules/HexRgbColorTest.php index 47e0e63a..3c50b15d 100644 --- a/tests/feature/Rules/HexRgbColorTest.php +++ b/tests/feature/Rules/HexRgbColorTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::hexRgbColor()->assert('invalid'), - fn(string $message) => expect($message)->toBe('"invalid" must be a hex RGB color') + fn(string $message) => expect($message)->toBe('"invalid" must be a hex RGB color'), )); test('Scenario #2', catchMessage( fn() => v::not(v::hexRgbColor())->assert('#808080'), - fn(string $message) => expect($message)->toBe('"#808080" must not be a hex RGB color') + fn(string $message) => expect($message)->toBe('"#808080" must not be a hex RGB color'), )); test('Scenario #3', catchFullMessage( fn() => v::hexRgbColor()->assert('invalid'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "invalid" must be a hex RGB color') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "invalid" must be a hex RGB color'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::hexRgbColor())->assert('#808080'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "#808080" must not be a hex RGB color') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "#808080" must not be a hex RGB color'), )); diff --git a/tests/feature/Rules/IbanTest.php b/tests/feature/Rules/IbanTest.php index afa125bf..2e90825c 100644 --- a/tests/feature/Rules/IbanTest.php +++ b/tests/feature/Rules/IbanTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::iban()->assert('SE35 5000 5880 7742'), - fn(string $message) => expect($message)->toBe('"SE35 5000 5880 7742" must be a valid IBAN') + fn(string $message) => expect($message)->toBe('"SE35 5000 5880 7742" must be a valid IBAN'), )); test('Scenario #2', catchMessage( fn() => v::not(v::iban())->assert('GB82 WEST 1234 5698 7654 32'), - fn(string $message) => expect($message)->toBe('"GB82 WEST 1234 5698 7654 32" must not be a valid IBAN') + fn(string $message) => expect($message)->toBe('"GB82 WEST 1234 5698 7654 32" must not be a valid IBAN'), )); test('Scenario #3', catchFullMessage( fn() => v::iban()->assert('NOT AN IBAN'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "NOT AN IBAN" must be a valid IBAN') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "NOT AN IBAN" must be a valid IBAN'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::iban())->assert('HU93 1160 0006 0000 0000 1234 5676'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "HU93 1160 0006 0000 0000 1234 5676" must not be a valid IBAN') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "HU93 1160 0006 0000 0000 1234 5676" must not be a valid IBAN'), )); diff --git a/tests/feature/Rules/IdenticalTest.php b/tests/feature/Rules/IdenticalTest.php index cdc4630e..0dc80355 100644 --- a/tests/feature/Rules/IdenticalTest.php +++ b/tests/feature/Rules/IdenticalTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::identical(123)->assert(321), - fn(string $message) => expect($message)->toBe('321 must be identical to 123') + fn(string $message) => expect($message)->toBe('321 must be identical to 123'), )); test('Scenario #2', catchMessage( fn() => v::not(v::identical(321))->assert(321), - fn(string $message) => expect($message)->toBe('321 must not be identical to 321') + fn(string $message) => expect($message)->toBe('321 must not be identical to 321'), )); test('Scenario #3', catchFullMessage( fn() => v::identical(123)->assert(321), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 321 must be identical to 123') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 321 must be identical to 123'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::identical(321))->assert(321), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 321 must not be identical to 321') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 321 must not be identical to 321'), )); diff --git a/tests/feature/Rules/ImageTest.php b/tests/feature/Rules/ImageTest.php index 3d9c493a..1c9a550d 100644 --- a/tests/feature/Rules/ImageTest.php +++ b/tests/feature/Rules/ImageTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::image()->assert('tests/fixtures/invalid-image.png'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/invalid-image.png" must be a valid image file') + fn(string $message) => expect($message)->toBe('"tests/fixtures/invalid-image.png" must be a valid image file'), )); test('Scenario #2', catchMessage( fn() => v::not(v::image())->assert('tests/fixtures/valid-image.png'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.png" must not be a valid image file') + fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.png" must not be a valid image file'), )); test('Scenario #3', catchFullMessage( fn() => v::image()->assert(new stdClass()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be a valid image file') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be a valid image file'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::image())->assert('tests/fixtures/valid-image.gif'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/valid-image.gif" must not be a valid image file') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/valid-image.gif" must not be a valid image file'), )); diff --git a/tests/feature/Rules/ImeiTest.php b/tests/feature/Rules/ImeiTest.php index cf0d64f0..5fb4050f 100644 --- a/tests/feature/Rules/ImeiTest.php +++ b/tests/feature/Rules/ImeiTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::imei()->assert('490154203237512'), - fn(string $message) => expect($message)->toBe('"490154203237512" must be a valid IMEI number') + fn(string $message) => expect($message)->toBe('"490154203237512" must be a valid IMEI number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::imei())->assert('350077523237513'), - fn(string $message) => expect($message)->toBe('"350077523237513" must not be a valid IMEI number') + fn(string $message) => expect($message)->toBe('"350077523237513" must not be a valid IMEI number'), )); test('Scenario #3', catchFullMessage( fn() => v::imei()->assert(null), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `null` must be a valid IMEI number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `null` must be a valid IMEI number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::imei())->assert('356938035643809'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "356938035643809" must not be a valid IMEI number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "356938035643809" must not be a valid IMEI number'), )); diff --git a/tests/feature/Rules/InTest.php b/tests/feature/Rules/InTest.php index fc24cfba..8f5bd730 100644 --- a/tests/feature/Rules/InTest.php +++ b/tests/feature/Rules/InTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::in([3, 2])->assert(1), - fn(string $message) => expect($message)->toBe('1 must be in `[3, 2]`') + fn(string $message) => expect($message)->toBe('1 must be in `[3, 2]`'), )); test('Scenario #2', catchMessage( fn() => v::not(v::in('foobar'))->assert('foo'), - fn(string $message) => expect($message)->toBe('"foo" must not be in "foobar"') + fn(string $message) => expect($message)->toBe('"foo" must not be in "foobar"'), )); test('Scenario #3', catchFullMessage( fn() => v::in([2, '1', 3], true)->assert('2'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "2" must be in `[2, "1", 3]`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "2" must be in `[2, "1", 3]`'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::in([2, '1', 3], true))->assert('1'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1" must not be in `[2, "1", 3]`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1" must not be in `[2, "1", 3]`'), )); diff --git a/tests/feature/Rules/InfiniteTest.php b/tests/feature/Rules/InfiniteTest.php index 5d85d65a..e32c1004 100644 --- a/tests/feature/Rules/InfiniteTest.php +++ b/tests/feature/Rules/InfiniteTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::infinite()->assert(-9), - fn(string $message) => expect($message)->toBe('-9 must be an infinite number') + fn(string $message) => expect($message)->toBe('-9 must be an infinite number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::infinite())->assert(INF), - fn(string $message) => expect($message)->toBe('`INF` must not be an infinite number') + fn(string $message) => expect($message)->toBe('`INF` must not be an infinite number'), )); test('Scenario #3', catchFullMessage( fn() => v::infinite()->assert(new stdClass()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be an infinite number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be an infinite number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::infinite())->assert(INF * -1), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `-INF` must not be an infinite number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `-INF` must not be an infinite number'), )); diff --git a/tests/feature/Rules/InstanceTest.php b/tests/feature/Rules/InstanceTest.php index 15e49e81..d1f302f5 100644 --- a/tests/feature/Rules/InstanceTest.php +++ b/tests/feature/Rules/InstanceTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::instance(DateTime::class)->assert(''), - fn(string $message) => expect($message)->toBe('"" must be an instance of `DateTime`') + fn(string $message) => expect($message)->toBe('"" must be an instance of `DateTime`'), )); test('Scenario #2', catchMessage( fn() => v::not(v::instance(Traversable::class))->assert(new ArrayObject()), - fn(string $message) => expect($message)->toBe('`ArrayObject { getArrayCopy() => [] }` must not be an instance of `Traversable`') + fn(string $message) => expect($message)->toBe('`ArrayObject { getArrayCopy() => [] }` must not be an instance of `Traversable`'), )); test('Scenario #3', catchFullMessage( fn() => v::instance(ArrayIterator::class)->assert(new stdClass()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be an instance of `ArrayIterator`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be an instance of `ArrayIterator`'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::instance(stdClass::class))->assert(new stdClass()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must not be an instance of `stdClass`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must not be an instance of `stdClass`'), )); diff --git a/tests/feature/Rules/IntTypeTest.php b/tests/feature/Rules/IntTypeTest.php index 6bb5957a..4dc50e61 100644 --- a/tests/feature/Rules/IntTypeTest.php +++ b/tests/feature/Rules/IntTypeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::intType()->assert(new stdClass()), - fn(string $message) => expect($message)->toBe('`stdClass {}` must be an integer') + fn(string $message) => expect($message)->toBe('`stdClass {}` must be an integer'), )); test('Scenario #2', catchMessage( fn() => v::not(v::intType())->assert(42), - fn(string $message) => expect($message)->toBe('42 must not be an integer') + fn(string $message) => expect($message)->toBe('42 must not be an integer'), )); test('Scenario #3', catchFullMessage( fn() => v::intType()->assert(INF), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `INF` must be an integer') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `INF` must be an integer'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::intType())->assert(1234567890), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 1234567890 must not be an integer') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 1234567890 must not be an integer'), )); diff --git a/tests/feature/Rules/IntValTest.php b/tests/feature/Rules/IntValTest.php index 429af7f2..a53c20eb 100644 --- a/tests/feature/Rules/IntValTest.php +++ b/tests/feature/Rules/IntValTest.php @@ -9,30 +9,30 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::intVal()->assert('42.33'), - fn(string $message) => expect($message)->toBe('"42.33" must be an integer value') + fn(string $message) => expect($message)->toBe('"42.33" must be an integer value'), )); test('Scenario #2', catchMessage( fn() => v::not(v::intVal())->assert(2), - fn(string $message) => expect($message)->toBe('2 must not be an integer value') + fn(string $message) => expect($message)->toBe('2 must not be an integer value'), )); test('Scenario #3', catchFullMessage( fn() => v::intVal()->assert('Foo'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "Foo" must be an integer value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "Foo" must be an integer value'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::intVal())->assert(3), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 3 must not be an integer value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 3 must not be an integer value'), )); test('Scenario #5', catchFullMessage( fn() => v::not(v::intVal())->assert(-42), - fn(string $fullMessage) => expect($fullMessage)->toBe('- -42 must not be an integer value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- -42 must not be an integer value'), )); test('Scenario #6', catchFullMessage( fn() => v::not(v::intVal())->assert('-42'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "-42" must not be an integer value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "-42" must not be an integer value'), )); diff --git a/tests/feature/Rules/IpTest.php b/tests/feature/Rules/IpTest.php index 1c0882ad..4170f07b 100644 --- a/tests/feature/Rules/IpTest.php +++ b/tests/feature/Rules/IpTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::ip()->assert('257.0.0.1'), - fn(string $message) => expect($message)->toBe('"257.0.0.1" must be an IP address') + fn(string $message) => expect($message)->toBe('"257.0.0.1" must be an IP address'), )); test('Scenario #2', catchMessage( fn() => v::not(v::ip())->assert('127.0.0.1'), - fn(string $message) => expect($message)->toBe('"127.0.0.1" must not be an IP address') + fn(string $message) => expect($message)->toBe('"127.0.0.1" must not be an IP address'), )); test('Scenario #3', catchMessage( fn() => v::ip('127.0.1.*')->assert('127.0.0.1'), - fn(string $message) => expect($message)->toBe('"127.0.0.1" must be an IP address in the 127.0.1.0-127.0.1.255 range') + fn(string $message) => expect($message)->toBe('"127.0.0.1" must be an IP address in the 127.0.1.0-127.0.1.255 range'), )); test('Scenario #4', catchMessage( fn() => v::not(v::ip('127.0.1.*'))->assert('127.0.1.1'), - fn(string $message) => expect($message)->toBe('"127.0.1.1" must not be an IP address in the 127.0.1.0-127.0.1.255 range') + fn(string $message) => expect($message)->toBe('"127.0.1.1" must not be an IP address in the 127.0.1.0-127.0.1.255 range'), )); test('Scenario #5', catchFullMessage( fn() => v::ip()->assert('257.0.0.1'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "257.0.0.1" must be an IP address') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "257.0.0.1" must be an IP address'), )); test('Scenario #6', catchFullMessage( fn() => v::not(v::ip())->assert('127.0.0.1'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "127.0.0.1" must not be an IP address') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "127.0.0.1" must not be an IP address'), )); test('Scenario #7', catchFullMessage( fn() => v::ip('127.0.1.*')->assert('127.0.0.1'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "127.0.0.1" must be an IP address in the 127.0.1.0-127.0.1.255 range') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "127.0.0.1" must be an IP address in the 127.0.1.0-127.0.1.255 range'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::ip('127.0.1.*'))->assert('127.0.1.1'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "127.0.1.1" must not be an IP address in the 127.0.1.0-127.0.1.255 range') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "127.0.1.1" must not be an IP address in the 127.0.1.0-127.0.1.255 range'), )); diff --git a/tests/feature/Rules/IsbnTest.php b/tests/feature/Rules/IsbnTest.php index 31648c8b..06749a1f 100644 --- a/tests/feature/Rules/IsbnTest.php +++ b/tests/feature/Rules/IsbnTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::isbn()->assert('ISBN-12: 978-0-596-52068-7'), - fn(string $message) => expect($message)->toBe('"ISBN-12: 978-0-596-52068-7" must be a valid ISBN') + fn(string $message) => expect($message)->toBe('"ISBN-12: 978-0-596-52068-7" must be a valid ISBN'), )); test('Scenario #2', catchMessage( fn() => v::not(v::isbn())->assert('ISBN-13: 978-0-596-52068-7'), - fn(string $message) => expect($message)->toBe('"ISBN-13: 978-0-596-52068-7" must not be a valid ISBN') + fn(string $message) => expect($message)->toBe('"ISBN-13: 978-0-596-52068-7" must not be a valid ISBN'), )); test('Scenario #3', catchFullMessage( fn() => v::isbn()->assert('978 10 596 52068 7'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "978 10 596 52068 7" must be a valid ISBN') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "978 10 596 52068 7" must be a valid ISBN'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::isbn())->assert('978 0 596 52068 7'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "978 0 596 52068 7" must not be a valid ISBN') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "978 0 596 52068 7" must not be a valid ISBN'), )); diff --git a/tests/feature/Rules/IterableTypeTest.php b/tests/feature/Rules/IterableTypeTest.php index 00d69985..25eb3afd 100644 --- a/tests/feature/Rules/IterableTypeTest.php +++ b/tests/feature/Rules/IterableTypeTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`null` must be iterable') ->and($fullMessage)->toBe('- `null` must be iterable') - ->and($messages)->toBe(['iterableType' => '`null` must be iterable']) + ->and($messages)->toBe(['iterableType' => '`null` must be iterable']), )); test('Inverted', catchAll( @@ -20,7 +20,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`[1, 2, 3]` must not iterable') ->and($fullMessage)->toBe('- `[1, 2, 3]` must not iterable') - ->and($messages)->toBe(['notIterableType' => '`[1, 2, 3]` must not iterable']) + ->and($messages)->toBe(['notIterableType' => '`[1, 2, 3]` must not iterable']), )); test('With template', catchAll( @@ -28,7 +28,7 @@ test('With template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not an iterable at all') ->and($fullMessage)->toBe('- Not an iterable at all') - ->and($messages)->toBe(['iterableType' => 'Not an iterable at all']) + ->and($messages)->toBe(['iterableType' => 'Not an iterable at all']), )); test('With name', catchAll( @@ -36,5 +36,5 @@ test('With name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Options must be iterable') ->and($fullMessage)->toBe('- Options must be iterable') - ->and($messages)->toBe(['iterableType' => 'Options must be iterable']) + ->and($messages)->toBe(['iterableType' => 'Options must be iterable']), )); diff --git a/tests/feature/Rules/IterableValTest.php b/tests/feature/Rules/IterableValTest.php index 133f6285..93a16232 100644 --- a/tests/feature/Rules/IterableValTest.php +++ b/tests/feature/Rules/IterableValTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::iterableVal()->assert(3), - fn(string $message) => expect($message)->toBe('3 must be an iterable value') + fn(string $message) => expect($message)->toBe('3 must be an iterable value'), )); test('Scenario #2', catchMessage( fn() => v::not(v::iterableVal())->assert([2, 3]), - fn(string $message) => expect($message)->toBe('`[2, 3]` must not be an iterable value') + fn(string $message) => expect($message)->toBe('`[2, 3]` must not be an iterable value'), )); test('Scenario #3', catchFullMessage( fn() => v::iterableVal()->assert('String'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "String" must be an iterable value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "String" must be an iterable value'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::iterableVal())->assert(new stdClass()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must not be an iterable value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must not be an iterable value'), )); diff --git a/tests/feature/Rules/JsonTest.php b/tests/feature/Rules/JsonTest.php index 1ed94e34..37ca941e 100644 --- a/tests/feature/Rules/JsonTest.php +++ b/tests/feature/Rules/JsonTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::json()->assert(false), - fn(string $message) => expect($message)->toBe('`false` must be a valid JSON string') + fn(string $message) => expect($message)->toBe('`false` must be a valid JSON string'), )); test('Scenario #2', catchMessage( fn() => v::not(v::json())->assert('{"foo": "bar", "number":1}'), - fn(string $message) => expect($message)->toBe('"{\\"foo\\": \\"bar\\", \\"number\\":1}" must not be a valid JSON string') + fn(string $message) => expect($message)->toBe('"{\\"foo\\": \\"bar\\", \\"number\\":1}" must not be a valid JSON string'), )); test('Scenario #3', catchFullMessage( fn() => v::json()->assert(new stdClass()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be a valid JSON string') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be a valid JSON string'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::json())->assert('{}'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "{}" must not be a valid JSON string') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "{}" must not be a valid JSON string'), )); diff --git a/tests/feature/Rules/KeyExistsTest.php b/tests/feature/Rules/KeyExistsTest.php index 727b2ca1..f2c368ec 100644 --- a/tests/feature/Rules/KeyExistsTest.php +++ b/tests/feature/Rules/KeyExistsTest.php @@ -12,7 +12,7 @@ test('Default mode', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be present') ->and($fullMessage)->toBe('- `.foo` must be present') - ->and($messages)->toBe(['foo' => '`.foo` must be present']) + ->and($messages)->toBe(['foo' => '`.foo` must be present']), )); test('Inverted mode', catchAll( @@ -20,7 +20,7 @@ test('Inverted mode', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must not be present') ->and($fullMessage)->toBe('- `.foo` must not be present') - ->and($messages)->toBe(['foo' => '`.foo` must not be present']) + ->and($messages)->toBe(['foo' => '`.foo` must not be present']), )); test('Custom name', catchAll( @@ -28,7 +28,7 @@ test('Custom name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Custom name must be present') ->and($fullMessage)->toBe('- Custom name must be present') - ->and($messages)->toBe(['foo' => 'Custom name must be present']) + ->and($messages)->toBe(['foo' => 'Custom name must be present']), )); test('Custom template', catchAll( @@ -36,5 +36,5 @@ test('Custom template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Custom template for `.foo`') ->and($fullMessage)->toBe('- Custom template for `.foo`') - ->and($messages)->toBe(['foo' => 'Custom template for `.foo`']) + ->and($messages)->toBe(['foo' => 'Custom template for `.foo`']), )); diff --git a/tests/feature/Rules/KeyOptionalTest.php b/tests/feature/Rules/KeyOptionalTest.php index 7b34e5e5..3556f0c3 100644 --- a/tests/feature/Rules/KeyOptionalTest.php +++ b/tests/feature/Rules/KeyOptionalTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be an integer') ->and($fullMessage)->toBe('- `.foo` must be an integer') - ->and($messages)->toBe(['foo' => '`.foo` must be an integer']) + ->and($messages)->toBe(['foo' => '`.foo` must be an integer']), )); test('Inverted', catchAll( @@ -20,7 +20,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must not be an integer') ->and($fullMessage)->toBe('- `.foo` must not be an integer') - ->and($messages)->toBe(['foo' => '`.foo` must not be an integer']) + ->and($messages)->toBe(['foo' => '`.foo` must not be an integer']), )); test('Inverted with missing key', catchAll( @@ -28,7 +28,7 @@ test('Inverted with missing key', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be present') ->and($fullMessage)->toBe('- `.foo` must be present') - ->and($messages)->toBe(['foo' => '`.foo` must be present']) + ->and($messages)->toBe(['foo' => '`.foo` must be present']), )); test('With wrapped name, default', catchAll( @@ -36,7 +36,7 @@ test('With wrapped name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must be an integer') ->and($fullMessage)->toBe('- Wrapped must be an integer') - ->and($messages)->toBe(['foo' => 'Wrapped must be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapped must be an integer']), )); test('With wrapped name, inverted', catchAll( @@ -44,7 +44,7 @@ test('With wrapped name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must not be an integer') ->and($fullMessage)->toBe('- Wrapped must not be an integer') - ->and($messages)->toBe(['foo' => 'Wrapped must not be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapped must not be an integer']), )); test('With wrapper name, default', catchAll( @@ -52,7 +52,7 @@ test('With wrapper name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must be an integer') ->and($fullMessage)->toBe('- Wrapper must be an integer') - ->and($messages)->toBe(['foo' => 'Wrapper must be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapper must be an integer']), )); test('With wrapper name, inverted', catchAll( @@ -60,7 +60,7 @@ test('With wrapper name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must not be an integer') ->and($fullMessage)->toBe('- Wrapper must not be an integer') - ->and($messages)->toBe(['foo' => 'Wrapper must not be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapper must not be an integer']), )); test('With "Not" name, inverted', catchAll( @@ -68,7 +68,7 @@ test('With "Not" name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not must not be an integer') ->and($fullMessage)->toBe('- Not must not be an integer') - ->and($messages)->toBe(['foo' => 'Not must not be an integer']) + ->and($messages)->toBe(['foo' => 'Not must not be an integer']), )); test('With template, default', catchAll( @@ -76,7 +76,7 @@ test('With template, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('That key is off-key') ->and($fullMessage)->toBe('- That key is off-key') - ->and($messages)->toBe(['foo' => 'That key is off-key']) + ->and($messages)->toBe(['foo' => 'That key is off-key']), )); test('With template, inverted', catchAll( @@ -84,5 +84,5 @@ test('With template, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('No off-key key') ->and($fullMessage)->toBe('- No off-key key') - ->and($messages)->toBe(['foo' => 'No off-key key']) + ->and($messages)->toBe(['foo' => 'No off-key key']), )); diff --git a/tests/feature/Rules/KeySetTest.php b/tests/feature/Rules/KeySetTest.php index 70ad4c89..5874cdc0 100644 --- a/tests/feature/Rules/KeySetTest.php +++ b/tests/feature/Rules/KeySetTest.php @@ -12,7 +12,7 @@ test('one rule / one failed', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be an integer') ->and($fullMessage)->toBe('- `.foo` must be an integer') - ->and($messages)->toBe(['foo' => '`.foo` must be an integer']) + ->and($messages)->toBe(['foo' => '`.foo` must be an integer']), )); test('one rule / one missing key', catchAll( @@ -20,7 +20,7 @@ test('one rule / one missing key', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be present') ->and($fullMessage)->toBe('- `.foo` must be present') - ->and($messages)->toBe(['foo' => '`.foo` must be present']) + ->and($messages)->toBe(['foo' => '`.foo` must be present']), )); test('one rule / one extra key', catchAll( @@ -28,7 +28,7 @@ test('one rule / one extra key', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.bar` must not be present') ->and($fullMessage)->toBe('- `.bar` must not be present') - ->and($messages)->toBe(['bar' => '`.bar` must not be present']) + ->and($messages)->toBe(['bar' => '`.bar` must not be present']), )); test('one rule / one extra key / one missing key', catchAll( @@ -44,7 +44,7 @@ test('one rule / one extra key / one missing key', catchAll( '__root__' => '`["bar": true]` contains both missing and extra keys', 'foo' => '`.foo` must be present', 'bar' => '`.bar` must not be present', - ]) + ]), )); test('one rule / two extra keys', catchAll( @@ -60,7 +60,7 @@ test('one rule / two extra keys', catchAll( '__root__' => '`["foo": 42, "bar": "string", "baz": true]` contains extra keys', 'bar' => '`.bar` must not be present', 'baz' => '`.baz` must not be present', - ]) + ]), )); test('one rule / more than ten extra keys', catchAll( @@ -107,7 +107,7 @@ test('one rule / more than ten extra keys', catchAll( 'waldo' => '`.waldo` must not be present', 'fred' => '`.fred` must not be present', 'plugh' => '`.plugh` must not be present', - ]) + ]), )); test('multiple rules / one failed', catchAll( @@ -115,7 +115,7 @@ test('multiple rules / one failed', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.bar` must be present') ->and($fullMessage)->toBe('- `.bar` must be present') - ->and($messages)->toBe(['bar' => '`.bar` must be present']) + ->and($messages)->toBe(['bar' => '`.bar` must be present']), )); test('multiple rules / all failed', catchAll( @@ -131,7 +131,7 @@ test('multiple rules / all failed', catchAll( '__root__' => '`[]` contains missing keys', 'foo' => '`.foo` must be present', 'bar' => '`.bar` must be present', - ]) + ]), )); test('multiple rules / one extra key', catchAll( @@ -142,7 +142,7 @@ test('multiple rules / one extra key', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.baz` must not be present') ->and($fullMessage)->toBe('- `.baz` must not be present') - ->and($messages)->toBe(['baz' => '`.baz` must not be present']) + ->and($messages)->toBe(['baz' => '`.baz` must not be present']), )); test('multiple rules / one extra key / one missing', catchAll( @@ -161,7 +161,7 @@ test('multiple rules / one extra key / one missing', catchAll( '__root__' => '`["bar": "string", "baz": true]` contains both missing and extra keys', 'foo' => '`.foo` must be present', 'baz' => '`.baz` must not be present', - ]) + ]), )); test('multiple rules / two extra keys', catchAll( @@ -181,7 +181,7 @@ test('multiple rules / two extra keys', catchAll( '__root__' => '`["foo": 42, "bar": "string", "baz": true, "qux": false]` contains extra keys', 'qux' => '`.qux` must be an integer', 'baz' => '`.baz` must not be present', - ]) + ]), )); test('multiple rules / all failed validation', catchAll( @@ -202,7 +202,7 @@ test('multiple rules / all failed validation', catchAll( '__root__' => '`["foo": 42, "bar": "string", "baz": true]` validation failed', 'bar' => '`.bar` must be an integer', 'baz' => '`.baz` must be an integer', - ]) + ]), )); test('multiple rules / single missing key / single failed validation', catchAll( @@ -224,5 +224,5 @@ test('multiple rules / single missing key / single failed validation', catchAll( '__root__' => '`["foo": 42, "bar": "string"]` contains missing keys', 'bar' => '`.bar` must be an integer', 'baz' => '`.baz` must be present', - ]) + ]), )); diff --git a/tests/feature/Rules/KeyTest.php b/tests/feature/Rules/KeyTest.php index 85564a5b..80a43607 100644 --- a/tests/feature/Rules/KeyTest.php +++ b/tests/feature/Rules/KeyTest.php @@ -12,7 +12,7 @@ test('Missing key', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be present') ->and($fullMessage)->toBe('- `.foo` must be present') - ->and($messages)->toBe(['foo' => '`.foo` must be present']) + ->and($messages)->toBe(['foo' => '`.foo` must be present']), )); test('Default', catchAll( @@ -20,7 +20,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be an integer') ->and($fullMessage)->toBe('- `.foo` must be an integer') - ->and($messages)->toBe(['foo' => '`.foo` must be an integer']) + ->and($messages)->toBe(['foo' => '`.foo` must be an integer']), )); test('Inverted', catchAll( @@ -28,7 +28,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must not be an integer') ->and($fullMessage)->toBe('- `.foo` must not be an integer') - ->and($messages)->toBe(['foo' => '`.foo` must not be an integer']) + ->and($messages)->toBe(['foo' => '`.foo` must not be an integer']), )); test('Double-inverted with missing key', catchAll( @@ -36,7 +36,7 @@ test('Double-inverted with missing key', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be present') ->and($fullMessage)->toBe('- `.foo` must be present') - ->and($messages)->toBe(['foo' => '`.foo` must be present']) + ->and($messages)->toBe(['foo' => '`.foo` must be present']), )); test('With wrapped name, missing key', catchAll( @@ -44,7 +44,7 @@ test('With wrapped name, missing key', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must be present') ->and($fullMessage)->toBe('- Wrapped must be present') - ->and($messages)->toBe(['foo' => 'Wrapped must be present']) + ->and($messages)->toBe(['foo' => 'Wrapped must be present']), )); test('With wrapped name, default', catchAll( @@ -52,7 +52,7 @@ test('With wrapped name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must be an integer') ->and($fullMessage)->toBe('- Wrapped must be an integer') - ->and($messages)->toBe(['foo' => 'Wrapped must be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapped must be an integer']), )); test('With wrapped name, inverted', catchAll( @@ -60,7 +60,7 @@ test('With wrapped name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must not be an integer') ->and($fullMessage)->toBe('- Wrapped must not be an integer') - ->and($messages)->toBe(['foo' => 'Wrapped must not be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapped must not be an integer']), )); test('With wrapper name, default', catchAll( @@ -68,7 +68,7 @@ test('With wrapper name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must be an integer') ->and($fullMessage)->toBe('- Wrapper must be an integer') - ->and($messages)->toBe(['foo' => 'Wrapper must be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapper must be an integer']), )); test('With wrapper name, missing key', catchAll( @@ -76,7 +76,7 @@ test('With wrapper name, missing key', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must be present') ->and($fullMessage)->toBe('- Wrapper must be present') - ->and($messages)->toBe(['foo' => 'Wrapper must be present']) + ->and($messages)->toBe(['foo' => 'Wrapper must be present']), )); test('With wrapper name, inverted', catchAll( @@ -84,7 +84,7 @@ test('With wrapper name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must not be an integer') ->and($fullMessage)->toBe('- Wrapper must not be an integer') - ->and($messages)->toBe(['foo' => 'Wrapper must not be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapper must not be an integer']), )); test('With "Not" name, inverted', catchAll( @@ -92,7 +92,7 @@ test('With "Not" name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not must not be an integer') ->and($fullMessage)->toBe('- Not must not be an integer') - ->and($messages)->toBe(['foo' => 'Not must not be an integer']) + ->and($messages)->toBe(['foo' => 'Not must not be an integer']), )); test('With template, default', catchAll( @@ -100,7 +100,7 @@ test('With template, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('That key is off-key') ->and($fullMessage)->toBe('- That key is off-key') - ->and($messages)->toBe(['foo' => 'That key is off-key']) + ->and($messages)->toBe(['foo' => 'That key is off-key']), )); test('With template, inverted', catchAll( @@ -108,5 +108,5 @@ test('With template, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('No off-key key') ->and($fullMessage)->toBe('- No off-key key') - ->and($messages)->toBe(['foo' => 'No off-key key']) + ->and($messages)->toBe(['foo' => 'No off-key key']), )); diff --git a/tests/feature/Rules/LanguageCodeTest.php b/tests/feature/Rules/LanguageCodeTest.php index 3b25f769..f2f12ff0 100644 --- a/tests/feature/Rules/LanguageCodeTest.php +++ b/tests/feature/Rules/LanguageCodeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::languageCode()->assert(null), - fn(string $message) => expect($message)->toBe('`null` must be a valid language code') + fn(string $message) => expect($message)->toBe('`null` must be a valid language code'), )); test('Scenario #2', catchMessage( fn() => v::not(v::languageCode())->assert('pt'), - fn(string $message) => expect($message)->toBe('"pt" must not be a valid language code') + fn(string $message) => expect($message)->toBe('"pt" must not be a valid language code'), )); test('Scenario #3', catchFullMessage( fn() => v::languageCode()->assert('por'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "por" must be a valid language code') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "por" must be a valid language code'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::languageCode())->assert('en'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "en" must not be a valid language code') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "en" must not be a valid language code'), )); diff --git a/tests/feature/Rules/LazyTest.php b/tests/feature/Rules/LazyTest.php index 23614653..776909c6 100644 --- a/tests/feature/Rules/LazyTest.php +++ b/tests/feature/Rules/LazyTest.php @@ -9,80 +9,80 @@ declare(strict_types=1); test('Default', catchAll( fn() => v::lazy( - fn() => v::intType() + fn() => v::intType(), )->assert(true), fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`true` must be an integer') ->and($fullMessage)->toBe('- `true` must be an integer') - ->and($messages)->toBe(['intType' => '`true` must be an integer']) + ->and($messages)->toBe(['intType' => '`true` must be an integer']), )); test('Inverted', catchAll( fn() => v::not(v::lazy( - fn() => v::intType() + fn() => v::intType(), ))->assert(2), fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('2 must not be an integer') ->and($fullMessage)->toBe('- 2 must not be an integer') - ->and($messages)->toBe(['notIntType' => '2 must not be an integer']) + ->and($messages)->toBe(['notIntType' => '2 must not be an integer']), )); test('With created name, default', catchAll( fn() => v::lazy( - fn() => v::intType()->setName('Created') + fn() => v::intType()->setName('Created'), )->setName('Wrapper')->assert(true), fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Created must be an integer') ->and($fullMessage)->toBe('- Created must be an integer') - ->and($messages)->toBe(['intType' => 'Created must be an integer']) + ->and($messages)->toBe(['intType' => 'Created must be an integer']), )); test('With wrapper name, default', catchAll( fn() => v::lazy( - fn() => v::intType() + fn() => v::intType(), )->setName('Wrapper')->assert(true), fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must be an integer') ->and($fullMessage)->toBe('- Wrapper must be an integer') - ->and($messages)->toBe(['intType' => 'Wrapper must be an integer']) + ->and($messages)->toBe(['intType' => 'Wrapper must be an integer']), )); test('With created name, inverted', catchAll( fn() => v::not(v::lazy( - fn() => v::intType()->setName('Created') + fn() => v::intType()->setName('Created'), )->setName('Wrapped'))->setName('Not')->assert(2), fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Created must not be an integer') ->and($fullMessage)->toBe('- Created must not be an integer') - ->and($messages)->toBe(['notIntType' => 'Created must not be an integer']) + ->and($messages)->toBe(['notIntType' => 'Created must not be an integer']), )); test('With wrapper name, inverted', catchAll( fn() => v::not(v::lazy( - fn() => v::intType() + fn() => v::intType(), )->setName('Wrapped'))->setName('Not')->assert(2), fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must not be an integer') ->and($fullMessage)->toBe('- Wrapped must not be an integer') - ->and($messages)->toBe(['notIntType' => 'Wrapped must not be an integer']) + ->and($messages)->toBe(['notIntType' => 'Wrapped must not be an integer']), )); test('With not name, inverted', catchAll( fn() => v::not(v::lazy( - fn() => v::intType() + fn() => v::intType(), ))->setName('Not')->assert(2), fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not must not be an integer') ->and($fullMessage)->toBe('- Not must not be an integer') - ->and($messages)->toBe(['notIntType' => 'Not must not be an integer']) + ->and($messages)->toBe(['notIntType' => 'Not must not be an integer']), )); test('With template, default', catchAll( fn() => v::lazy( - fn() => v::intType() + fn() => v::intType(), )->assert(true, 'Lazy lizards lounging like lords in the local lagoon'), fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Lazy lizards lounging like lords in the local lagoon') ->and($fullMessage)->toBe('- Lazy lizards lounging like lords in the local lagoon') - ->and($messages)->toBe(['intType' => 'Lazy lizards lounging like lords in the local lagoon']) + ->and($messages)->toBe(['intType' => 'Lazy lizards lounging like lords in the local lagoon']), )); diff --git a/tests/feature/Rules/LeapDateTest.php b/tests/feature/Rules/LeapDateTest.php index 3814a87b..e9a6b2f3 100644 --- a/tests/feature/Rules/LeapDateTest.php +++ b/tests/feature/Rules/LeapDateTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::leapDate('Y-m-d')->assert('1989-02-29'), - fn(string $message) => expect($message)->toBe('"1989-02-29" must be a valid leap date') + fn(string $message) => expect($message)->toBe('"1989-02-29" must be a valid leap date'), )); test('Scenario #2', catchMessage( fn() => v::not(v::leapDate('Y-m-d'))->assert('1988-02-29'), - fn(string $message) => expect($message)->toBe('"1988-02-29" must not be a leap date') + fn(string $message) => expect($message)->toBe('"1988-02-29" must not be a leap date'), )); test('Scenario #3', catchFullMessage( fn() => v::leapDate('Y-m-d')->assert('1990-02-29'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1990-02-29" must be a valid leap date') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1990-02-29" must be a valid leap date'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::leapDate('Y-m-d'))->assert('1992-02-29'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1992-02-29" must not be a leap date') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1992-02-29" must not be a leap date'), )); diff --git a/tests/feature/Rules/LeapYearTest.php b/tests/feature/Rules/LeapYearTest.php index 27a60780..24c0b185 100644 --- a/tests/feature/Rules/LeapYearTest.php +++ b/tests/feature/Rules/LeapYearTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::leapYear()->assert('2009'), - fn(string $message) => expect($message)->toBe('"2009" must be a valid leap year') + fn(string $message) => expect($message)->toBe('"2009" must be a valid leap year'), )); test('Scenario #2', catchMessage( fn() => v::not(v::leapYear())->assert('2008'), - fn(string $message) => expect($message)->toBe('"2008" must not be a leap year') + fn(string $message) => expect($message)->toBe('"2008" must not be a leap year'), )); test('Scenario #3', catchFullMessage( fn() => v::leapYear()->assert('2009-02-29'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "2009-02-29" must be a valid leap year') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "2009-02-29" must be a valid leap year'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::leapYear())->assert('2008'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "2008" must not be a leap year') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "2008" must not be a leap year'), )); diff --git a/tests/feature/Rules/LengthTest.php b/tests/feature/Rules/LengthTest.php index d3d20965..cff8de69 100644 --- a/tests/feature/Rules/LengthTest.php +++ b/tests/feature/Rules/LengthTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The length of "tulip" must be equal to 3') ->and($fullMessage)->toBe('- The length of "tulip" must be equal to 3') - ->and($messages)->toBe(['lengthEquals' => 'The length of "tulip" must be equal to 3']) + ->and($messages)->toBe(['lengthEquals' => 'The length of "tulip" must be equal to 3']), )); test('Inverted wrapped', catchAll( @@ -20,7 +20,7 @@ test('Inverted wrapped', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The length of "rose" must not be equal to 4') ->and($fullMessage)->toBe('- The length of "rose" must not be equal to 4') - ->and($messages)->toBe(['lengthNotEquals' => 'The length of "rose" must not be equal to 4']) + ->and($messages)->toBe(['lengthNotEquals' => 'The length of "rose" must not be equal to 4']), )); test('Inverted wrapper', catchAll( @@ -28,7 +28,7 @@ test('Inverted wrapper', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The length of "fern" must not be equal to 4') ->and($fullMessage)->toBe('- The length of "fern" must not be equal to 4') - ->and($messages)->toBe(['notLengthEquals' => 'The length of "fern" must not be equal to 4']) + ->and($messages)->toBe(['notLengthEquals' => 'The length of "fern" must not be equal to 4']), )); test('With template', catchAll( @@ -36,7 +36,7 @@ test('With template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('This is a template') ->and($fullMessage)->toBe('- This is a template') - ->and($messages)->toBe(['lengthEquals' => 'This is a template']) + ->and($messages)->toBe(['lengthEquals' => 'This is a template']), )); test('With wrapper name', catchAll( @@ -44,7 +44,7 @@ test('With wrapper name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The length of Cactus must be equal to 3') ->and($fullMessage)->toBe('- The length of Cactus must be equal to 3') - ->and($messages)->toBe(['lengthEquals' => 'The length of Cactus must be equal to 3']) + ->and($messages)->toBe(['lengthEquals' => 'The length of Cactus must be equal to 3']), )); test('Chained wrapped rule', catchAll( @@ -60,5 +60,5 @@ test('Chained wrapped rule', catchAll( '__root__' => '`[]` must pass all the rules', 'lengthBetween' => 'The length of `[]` must be between 5 and 7', 'lengthOdd' => 'The length of `[]` must be an odd number', - ]) + ]), )); diff --git a/tests/feature/Rules/LessThanOrEqualTest.php b/tests/feature/Rules/LessThanOrEqualTest.php index 91d90460..f72fd7d6 100644 --- a/tests/feature/Rules/LessThanOrEqualTest.php +++ b/tests/feature/Rules/LessThanOrEqualTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::lessThanOrEqual(10)->assert(11), - fn(string $message) => expect($message)->toBe('11 must be less than or equal to 10') + fn(string $message) => expect($message)->toBe('11 must be less than or equal to 10'), )); test('Scenario #2', catchMessage( fn() => v::not(v::lessThanOrEqual(10))->assert(5), - fn(string $message) => expect($message)->toBe('5 must be greater than 10') + fn(string $message) => expect($message)->toBe('5 must be greater than 10'), )); test('Scenario #3', catchFullMessage( fn() => v::lessThanOrEqual('today')->assert('tomorrow'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tomorrow" must be less than or equal to "today"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tomorrow" must be less than or equal to "today"'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::lessThanOrEqual('b'))->assert('a'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must be greater than "b"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must be greater than "b"'), )); diff --git a/tests/feature/Rules/LessThanTest.php b/tests/feature/Rules/LessThanTest.php index ffe016f2..ad34888f 100644 --- a/tests/feature/Rules/LessThanTest.php +++ b/tests/feature/Rules/LessThanTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::lessThan(12)->assert(21), - fn(string $message) => expect($message)->toBe('21 must be less than 12') + fn(string $message) => expect($message)->toBe('21 must be less than 12'), )); test('Scenario #2', catchMessage( fn() => v::not(v::lessThan('today'))->assert('yesterday'), - fn(string $message) => expect($message)->toBe('"yesterday" must not be less than "today"') + fn(string $message) => expect($message)->toBe('"yesterday" must not be less than "today"'), )); test('Scenario #3', catchFullMessage( fn() => v::lessThan('1988-09-09')->assert('2018-09-09'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "2018-09-09" must be less than "1988-09-09"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "2018-09-09" must be less than "1988-09-09"'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::lessThan('b'))->assert('a'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must not be less than "b"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must not be less than "b"'), )); diff --git a/tests/feature/Rules/LowercaseTest.php b/tests/feature/Rules/LowercaseTest.php index aa3997f9..1a3329e0 100644 --- a/tests/feature/Rules/LowercaseTest.php +++ b/tests/feature/Rules/LowercaseTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::lowercase()->assert('UPPERCASE'), - fn(string $message) => expect($message)->toBe('"UPPERCASE" must contain only lowercase letters') + fn(string $message) => expect($message)->toBe('"UPPERCASE" must contain only lowercase letters'), )); test('Scenario #2', catchMessage( fn() => v::not(v::lowercase())->assert('lowercase'), - fn(string $message) => expect($message)->toBe('"lowercase" must not contain only lowercase letters') + fn(string $message) => expect($message)->toBe('"lowercase" must not contain only lowercase letters'), )); test('Scenario #3', catchFullMessage( fn() => v::lowercase()->assert('UPPERCASE'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "UPPERCASE" must contain only lowercase letters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "UPPERCASE" must contain only lowercase letters'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::lowercase())->assert('lowercase'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "lowercase" must not contain only lowercase letters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "lowercase" must not contain only lowercase letters'), )); diff --git a/tests/feature/Rules/LuhnTest.php b/tests/feature/Rules/LuhnTest.php index 84aa2107..8d67dfb6 100644 --- a/tests/feature/Rules/LuhnTest.php +++ b/tests/feature/Rules/LuhnTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::luhn()->assert('2222400041240021'), - fn(string $message) => expect($message)->toBe('"2222400041240021" must be a valid Luhn number') + fn(string $message) => expect($message)->toBe('"2222400041240021" must be a valid Luhn number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::luhn())->assert('2223000048400011'), - fn(string $message) => expect($message)->toBe('"2223000048400011" must not be a valid Luhn number') + fn(string $message) => expect($message)->toBe('"2223000048400011" must not be a valid Luhn number'), )); test('Scenario #3', catchFullMessage( fn() => v::luhn()->assert('340316193809334'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "340316193809334" must be a valid Luhn number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "340316193809334" must be a valid Luhn number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::luhn())->assert('6011000990139424'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "6011000990139424" must not be a valid Luhn number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "6011000990139424" must not be a valid Luhn number'), )); diff --git a/tests/feature/Rules/MacAddressTest.php b/tests/feature/Rules/MacAddressTest.php index 0902da86..d96a157e 100644 --- a/tests/feature/Rules/MacAddressTest.php +++ b/tests/feature/Rules/MacAddressTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::macAddress()->assert('00-11222:33:44:55'), - fn(string $message) => expect($message)->toBe('"00-11222:33:44:55" must be a valid MAC address') + fn(string $message) => expect($message)->toBe('"00-11222:33:44:55" must be a valid MAC address'), )); test('Scenario #2', catchMessage( fn() => v::not(v::macAddress())->assert('00:11:22:33:44:55'), - fn(string $message) => expect($message)->toBe('"00:11:22:33:44:55" must not be a valid MAC address') + fn(string $message) => expect($message)->toBe('"00:11:22:33:44:55" must not be a valid MAC address'), )); test('Scenario #3', catchFullMessage( fn() => v::macAddress()->assert('90-bc-nk:1a-dd-cc'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "90-bc-nk:1a-dd-cc" must be a valid MAC address') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "90-bc-nk:1a-dd-cc" must be a valid MAC address'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::macAddress())->assert('AF:0F:bd:12:44:ba'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "AF:0F:bd:12:44:ba" must not be a valid MAC address') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "AF:0F:bd:12:44:ba" must not be a valid MAC address'), )); diff --git a/tests/feature/Rules/MaxTest.php b/tests/feature/Rules/MaxTest.php index 713e6384..a900fd74 100644 --- a/tests/feature/Rules/MaxTest.php +++ b/tests/feature/Rules/MaxTest.php @@ -12,7 +12,7 @@ test('Non-iterable', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`null` must be iterable') ->and($fullMessage)->toBe('- `null` must be iterable') - ->and($messages)->toBe(['max' => '`null` must be iterable']) + ->and($messages)->toBe(['max' => '`null` must be iterable']), )); test('Empty', catchAll( @@ -20,7 +20,7 @@ test('Empty', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`[]` must not be empty') ->and($fullMessage)->toBe('- `[]` must not be empty') - ->and($messages)->toBe(['max' => '`[]` must not be empty']) + ->and($messages)->toBe(['max' => '`[]` must not be empty']), )); test('Default', catchAll( @@ -28,7 +28,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The maximum of `[1, 2, 3]` must be a negative number') ->and($fullMessage)->toBe('- The maximum of `[1, 2, 3]` must be a negative number') - ->and($messages)->toBe(['maxNegative' => 'The maximum of `[1, 2, 3]` must be a negative number']) + ->and($messages)->toBe(['maxNegative' => 'The maximum of `[1, 2, 3]` must be a negative number']), )); test('Inverted', catchAll( @@ -36,7 +36,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The maximum of `[-3, -2, -1]` must not be a negative number') ->and($fullMessage)->toBe('- The maximum of `[-3, -2, -1]` must not be a negative number') - ->and($messages)->toBe(['notMaxNegative' => 'The maximum of `[-3, -2, -1]` must not be a negative number']) + ->and($messages)->toBe(['notMaxNegative' => 'The maximum of `[-3, -2, -1]` must not be a negative number']), )); test('With wrapped name, default', catchAll( @@ -44,7 +44,7 @@ test('With wrapped name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The maximum of Wrapped must be a negative number') ->and($fullMessage)->toBe('- The maximum of Wrapped must be a negative number') - ->and($messages)->toBe(['maxNegative' => 'The maximum of Wrapped must be a negative number']) + ->and($messages)->toBe(['maxNegative' => 'The maximum of Wrapped must be a negative number']), )); test('With wrapper name, default', catchAll( @@ -52,7 +52,7 @@ test('With wrapper name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The maximum of Wrapper must be a negative number') ->and($fullMessage)->toBe('- The maximum of Wrapper must be a negative number') - ->and($messages)->toBe(['maxNegative' => 'The maximum of Wrapper must be a negative number']) + ->and($messages)->toBe(['maxNegative' => 'The maximum of Wrapper must be a negative number']), )); test('With wrapped name, inverted', catchAll( @@ -60,7 +60,7 @@ test('With wrapped name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The maximum of Wrapped must not be a negative number') ->and($fullMessage)->toBe('- The maximum of Wrapped must not be a negative number') - ->and($messages)->toBe(['notMaxNegative' => 'The maximum of Wrapped must not be a negative number']) + ->and($messages)->toBe(['notMaxNegative' => 'The maximum of Wrapped must not be a negative number']), )); test('With wrapper name, inverted', catchAll( @@ -68,7 +68,7 @@ test('With wrapper name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The maximum of Wrapper must not be a negative number') ->and($fullMessage)->toBe('- The maximum of Wrapper must not be a negative number') - ->and($messages)->toBe(['notMaxNegative' => 'The maximum of Wrapper must not be a negative number']) + ->and($messages)->toBe(['notMaxNegative' => 'The maximum of Wrapper must not be a negative number']), )); test('With template, default', catchAll( @@ -76,7 +76,7 @@ test('With template, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The maximum of the value is not what we expect') ->and($fullMessage)->toBe('- The maximum of the value is not what we expect') - ->and($messages)->toBe(['maxNegative' => 'The maximum of the value is not what we expect']) + ->and($messages)->toBe(['maxNegative' => 'The maximum of the value is not what we expect']), )); test('Chained wrapped rule', catchAll( @@ -92,5 +92,5 @@ test('Chained wrapped rule', catchAll( '__root__' => '`[1, 2, 3, 4]` must pass all the rules', 'maxBetween' => 'The maximum of `[1, 2, 3, 4]` must be between 5 and 7', 'maxOdd' => 'The maximum of `[1, 2, 3, 4]` must be an odd number', - ]) + ]), )); diff --git a/tests/feature/Rules/MimetypeTest.php b/tests/feature/Rules/MimetypeTest.php index ed8b32d5..c09c16ef 100644 --- a/tests/feature/Rules/MimetypeTest.php +++ b/tests/feature/Rules/MimetypeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::mimetype('image/png')->assert('image.png'), - fn(string $message) => expect($message)->toBe('"image.png" must have the "image/png" MIME type') + fn(string $message) => expect($message)->toBe('"image.png" must have the "image/png" MIME type'), )); test('Scenario #2', catchMessage( fn() => v::not(v::mimetype('image/png'))->assert('tests/fixtures/valid-image.png'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.png" must not have the "image/png" MIME type') + fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.png" must not have the "image/png" MIME type'), )); test('Scenario #3', catchFullMessage( fn() => v::mimetype('image/png')->assert('tests/fixtures/invalid-image.png'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/invalid-image.png" must have the "image/png" MIME type') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/invalid-image.png" must have the "image/png" MIME type'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::mimetype('image/png'))->assert('tests/fixtures/valid-image.png'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/valid-image.png" must not have the "image/png" MIME type') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/valid-image.png" must not have the "image/png" MIME type'), )); diff --git a/tests/feature/Rules/MinTest.php b/tests/feature/Rules/MinTest.php index 5ec054dd..f2522c1f 100644 --- a/tests/feature/Rules/MinTest.php +++ b/tests/feature/Rules/MinTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The minimum of `[2, 3]` must be equal to 1') ->and($fullMessage)->toBe('- The minimum of `[2, 3]` must be equal to 1') - ->and($messages)->toBe(['minEquals' => 'The minimum of `[2, 3]` must be equal to 1']) + ->and($messages)->toBe(['minEquals' => 'The minimum of `[2, 3]` must be equal to 1']), )); test('Inverted', catchAll( @@ -20,7 +20,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The minimum of `[1, 2, 3]` must not be equal to 1') ->and($fullMessage)->toBe('- The minimum of `[1, 2, 3]` must not be equal to 1') - ->and($messages)->toBe(['notMinEquals' => 'The minimum of `[1, 2, 3]` must not be equal to 1']) + ->and($messages)->toBe(['notMinEquals' => 'The minimum of `[1, 2, 3]` must not be equal to 1']), )); test('With template', catchAll( @@ -28,7 +28,7 @@ test('With template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('That did not go as planned') ->and($fullMessage)->toBe('- That did not go as planned') - ->and($messages)->toBe(['minEquals' => 'That did not go as planned']) + ->and($messages)->toBe(['minEquals' => 'That did not go as planned']), )); test('With name', catchAll( @@ -36,7 +36,7 @@ test('With name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The minimum of Options must be equal to 1') ->and($fullMessage)->toBe('- The minimum of Options must be equal to 1') - ->and($messages)->toBe(['minEquals' => 'The minimum of Options must be equal to 1']) + ->and($messages)->toBe(['minEquals' => 'The minimum of Options must be equal to 1']), )); test('Chained wrapped rule', catchAll( @@ -52,5 +52,5 @@ test('Chained wrapped rule', catchAll( '__root__' => '`[2, 3, 4]` must pass all the rules', 'minBetween' => 'The minimum of `[2, 3, 4]` must be between 5 and 7', 'minOdd' => 'The minimum of `[2, 3, 4]` must be an odd number', - ]) + ]), )); diff --git a/tests/feature/Rules/MultipleTest.php b/tests/feature/Rules/MultipleTest.php index 3a5ae42c..3843047a 100644 --- a/tests/feature/Rules/MultipleTest.php +++ b/tests/feature/Rules/MultipleTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::multiple(3)->assert(22), - fn(string $message) => expect($message)->toBe('22 must be a multiple of 3') + fn(string $message) => expect($message)->toBe('22 must be a multiple of 3'), )); test('Scenario #2', catchMessage( fn() => v::not(v::multiple(3))->assert(9), - fn(string $message) => expect($message)->toBe('9 must not be a multiple of 3') + fn(string $message) => expect($message)->toBe('9 must not be a multiple of 3'), )); test('Scenario #3', catchFullMessage( fn() => v::multiple(2)->assert(5), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 5 must be a multiple of 2') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 5 must be a multiple of 2'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::multiple(5))->assert(25), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 25 must not be a multiple of 5') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 25 must not be a multiple of 5'), )); diff --git a/tests/feature/Rules/NamedTest.php b/tests/feature/Rules/NamedTest.php index 1bf46ceb..168f897b 100644 --- a/tests/feature/Rules/NamedTest.php +++ b/tests/feature/Rules/NamedTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Potato must be a string') ->and($fullMessage)->toBe('- Potato must be a string') - ->and($messages)->toBe(['stringType' => 'Potato must be a string']) + ->and($messages)->toBe(['stringType' => 'Potato must be a string']), )); test('Inverted', catchAll( @@ -20,7 +20,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Zucchini must not be an integer') ->and($fullMessage)->toBe('- Zucchini must not be an integer') - ->and($messages)->toBe(['notIntType' => 'Zucchini must not be an integer']) + ->and($messages)->toBe(['notIntType' => 'Zucchini must not be an integer']), )); test('Template in Validator', catchAll( @@ -30,7 +30,7 @@ test('Template in Validator', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Eggplant must be a string') ->and($fullMessage)->toBe('- Eggplant must be a string') - ->and($messages)->toBe(['stringType' => 'Eggplant must be a string']) + ->and($messages)->toBe(['stringType' => 'Eggplant must be a string']), )); test('With bound', catchAll( @@ -38,7 +38,7 @@ test('With bound', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Pumpkin must be an object') ->and($fullMessage)->toBe('- Pumpkin must be an object') - ->and($messages)->toBe(['attributes' => 'Pumpkin must be an object']) + ->and($messages)->toBe(['attributes' => 'Pumpkin must be an object']), )); test('With key that does not exist', catchAll( @@ -46,7 +46,7 @@ test('With key that does not exist', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Paprika must be present') ->and($fullMessage)->toBe('- Paprika must be present') - ->and($messages)->toBe(['vegetable' => 'Paprika must be present']) + ->and($messages)->toBe(['vegetable' => 'Paprika must be present']), )); test('With property that does not exist', catchAll( @@ -54,7 +54,7 @@ test('With property that does not exist', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Broccoli must be present') ->and($fullMessage)->toBe('- Broccoli must be present') - ->and($messages)->toBe(['vegetable' => 'Broccoli must be present']) + ->and($messages)->toBe(['vegetable' => 'Broccoli must be present']), )); test('With key that fails validation', catchAll( @@ -62,7 +62,7 @@ test('With key that fails validation', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Artichoke must be a string') ->and($fullMessage)->toBe('- Artichoke must be a string') - ->and($messages)->toBe(['vegetable' => 'Artichoke must be a string']) + ->and($messages)->toBe(['vegetable' => 'Artichoke must be a string']), )); test('With nested key that fails validation', catchAll( @@ -73,7 +73,7 @@ test('With nested key that fails validation', catchAll( ->key('root', v::stringType()) ->key('stems', v::stringType()) ->keyExists('fruits'), - 'Vegetables' + 'Vegetables', ), )->assert(['vegetables' => ['root' => 12, 'stems' => 12]]), fn(string $message, string $fullMessage, array $messages) => expect() @@ -89,5 +89,5 @@ test('With nested key that fails validation', catchAll( 'root' => '`.root` must be a string', 'stems' => '`.stems` must be a string', 'fruits' => '`.fruits` must be present', - ]) + ]), )); diff --git a/tests/feature/Rules/NegativeTest.php b/tests/feature/Rules/NegativeTest.php index a140a2fb..311f5d22 100644 --- a/tests/feature/Rules/NegativeTest.php +++ b/tests/feature/Rules/NegativeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::negative()->assert(16), - fn(string $message) => expect($message)->toBe('16 must be a negative number') + fn(string $message) => expect($message)->toBe('16 must be a negative number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::negative())->assert(-10), - fn(string $message) => expect($message)->toBe('-10 must not be a negative number') + fn(string $message) => expect($message)->toBe('-10 must not be a negative number'), )); test('Scenario #3', catchFullMessage( fn() => v::negative()->assert('a'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must be a negative number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must be a negative number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::negative())->assert('-144'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "-144" must not be a negative number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "-144" must not be a negative number'), )); diff --git a/tests/feature/Rules/NfeAccessKeyTest.php b/tests/feature/Rules/NfeAccessKeyTest.php index 6790fba7..eaf4ce56 100644 --- a/tests/feature/Rules/NfeAccessKeyTest.php +++ b/tests/feature/Rules/NfeAccessKeyTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::nfeAccessKey()->assert('31841136830118868211870485416765268625116906'), - fn(string $message) => expect($message)->toBe('"31841136830118868211870485416765268625116906" must be a valid NFe access key') + fn(string $message) => expect($message)->toBe('"31841136830118868211870485416765268625116906" must be a valid NFe access key'), )); test('Scenario #2', catchMessage( fn() => v::not(v::nfeAccessKey())->assert('52060433009911002506550120000007800267301615'), - fn(string $message) => expect($message)->toBe('"52060433009911002506550120000007800267301615" must not be a valid NFe access key') + fn(string $message) => expect($message)->toBe('"52060433009911002506550120000007800267301615" must not be a valid NFe access key'), )); test('Scenario #3', catchFullMessage( fn() => v::nfeAccessKey()->assert('31841136830118868211870485416765268625116906'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "31841136830118868211870485416765268625116906" must be a valid NFe access key') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "31841136830118868211870485416765268625116906" must be a valid NFe access key'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::nfeAccessKey())->assert('52060433009911002506550120000007800267301615'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "52060433009911002506550120000007800267301615" must not be a valid NFe access key') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "52060433009911002506550120000007800267301615" must not be a valid NFe access key'), )); diff --git a/tests/feature/Rules/NifTest.php b/tests/feature/Rules/NifTest.php index f4a6855b..4b96fb3c 100644 --- a/tests/feature/Rules/NifTest.php +++ b/tests/feature/Rules/NifTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::nif()->assert('06357771Q'), - fn(string $message) => expect($message)->toBe('"06357771Q" must be a valid NIF') + fn(string $message) => expect($message)->toBe('"06357771Q" must be a valid NIF'), )); test('Scenario #2', catchMessage( fn() => v::not(v::nif())->assert('71110316C'), - fn(string $message) => expect($message)->toBe('"71110316C" must not be a valid NIF') + fn(string $message) => expect($message)->toBe('"71110316C" must not be a valid NIF'), )); test('Scenario #3', catchFullMessage( fn() => v::nif()->assert('06357771Q'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "06357771Q" must be a valid NIF') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "06357771Q" must be a valid NIF'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::nif())->assert('R1332622H'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "R1332622H" must not be a valid NIF') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "R1332622H" must not be a valid NIF'), )); diff --git a/tests/feature/Rules/NipTest.php b/tests/feature/Rules/NipTest.php index 6beecf65..da336508 100644 --- a/tests/feature/Rules/NipTest.php +++ b/tests/feature/Rules/NipTest.php @@ -11,20 +11,20 @@ require_once 'vendor/autoload.php'; test('Scenario #1', catchMessage( fn() => v::nip()->assert('1645865778'), - fn(string $message) => expect($message)->toBe('"1645865778" must be a valid Polish VAT identification number') + fn(string $message) => expect($message)->toBe('"1645865778" must be a valid Polish VAT identification number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::nip())->assert('1645865777'), - fn(string $message) => expect($message)->toBe('"1645865777" must not be a valid Polish VAT identification number') + fn(string $message) => expect($message)->toBe('"1645865777" must not be a valid Polish VAT identification number'), )); test('Scenario #3', catchFullMessage( fn() => v::nip()->assert('1645865778'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1645865778" must be a valid Polish VAT identification number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1645865778" must be a valid Polish VAT identification number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::nip())->assert('1645865777'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1645865777" must not be a valid Polish VAT identification number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1645865777" must not be a valid Polish VAT identification number'), )); diff --git a/tests/feature/Rules/NoTest.php b/tests/feature/Rules/NoTest.php index ce761559..19a87675 100644 --- a/tests/feature/Rules/NoTest.php +++ b/tests/feature/Rules/NoTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::not(v::no())->assert('No'), - fn(string $message) => expect($message)->toBe('"No" must not be similar to "No"') + fn(string $message) => expect($message)->toBe('"No" must not be similar to "No"'), )); test('Scenario #2', catchMessage( fn() => v::no()->assert('Yes'), - fn(string $message) => expect($message)->toBe('"Yes" must be similar to "No"') + fn(string $message) => expect($message)->toBe('"Yes" must be similar to "No"'), )); test('Scenario #3', catchFullMessage( fn() => v::not(v::no())->assert('No'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "No" must not be similar to "No"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "No" must not be similar to "No"'), )); test('Scenario #4', catchFullMessage( fn() => v::no()->assert('Yes'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "Yes" must be similar to "No"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "Yes" must be similar to "No"'), )); diff --git a/tests/feature/Rules/NoWhitespaceTest.php b/tests/feature/Rules/NoWhitespaceTest.php index 677abac3..b72d668b 100644 --- a/tests/feature/Rules/NoWhitespaceTest.php +++ b/tests/feature/Rules/NoWhitespaceTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::noWhitespace()->assert('w poiur'), - fn(string $message) => expect($message)->toBe('"w poiur" must not contain whitespaces') + fn(string $message) => expect($message)->toBe('"w poiur" must not contain whitespaces'), )); test('Scenario #2', catchMessage( fn() => v::not(v::noWhitespace())->assert('wpoiur'), - fn(string $message) => expect($message)->toBe('"wpoiur" must contain at least one whitespace') + fn(string $message) => expect($message)->toBe('"wpoiur" must contain at least one whitespace'), )); test('Scenario #3', catchFullMessage( fn() => v::noWhitespace()->assert('w poiur'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "w poiur" must not contain whitespaces') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "w poiur" must not contain whitespaces'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::noWhitespace())->assert('wpoiur'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "wpoiur" must contain at least one whitespace') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "wpoiur" must contain at least one whitespace'), )); diff --git a/tests/feature/Rules/NoneOfTest.php b/tests/feature/Rules/NoneOfTest.php index 8ccd65ff..9d7e1bd6 100644 --- a/tests/feature/Rules/NoneOfTest.php +++ b/tests/feature/Rules/NoneOfTest.php @@ -20,7 +20,7 @@ test('Default: fail, fail', catchAll( '__root__' => '-1 must pass all the rules', 'intType' => '-1 must not be an integer', 'negative' => '-1 must not be a negative number', - ]) + ]), )); test('Default: pass, fail', catchAll( @@ -30,9 +30,7 @@ test('Default: pass, fail', catchAll( ->and($fullMessage)->toBe(<<<'FULL_MESSAGE' - "string" must not be a string FULL_MESSAGE) - ->and($messages)->toBe([ - 'stringType' => '"string" must not be a string', - ]) + ->and($messages)->toBe(['stringType' => '"string" must not be a string']), )); test('Default: pass, fail, fail', catchAll( @@ -48,7 +46,7 @@ test('Default: pass, fail, fail', catchAll( '__root__' => '"string" must pass the rules', 'alpha' => '"string" must not contain letters (a-z)', 'stringType' => '"string" must not be a string', - ]) + ]), )); test('Inverted: fail, fail', catchAll( @@ -64,5 +62,5 @@ test('Inverted: fail, fail', catchAll( '__root__' => '"string" must pass the rules', 'intType' => '"string" must be an integer', 'negative' => '"string" must be a negative number', - ]) + ]), )); diff --git a/tests/feature/Rules/NotBlankTest.php b/tests/feature/Rules/NotBlankTest.php index 1395f7a1..7fd733c6 100644 --- a/tests/feature/Rules/NotBlankTest.php +++ b/tests/feature/Rules/NotBlankTest.php @@ -9,30 +9,30 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::notBlank()->assert(null), - fn(string $message) => expect($message)->toBe('`null` must not be blank') + fn(string $message) => expect($message)->toBe('`null` must not be blank'), )); test('Scenario #2', catchMessage( fn() => v::notBlank()->setName('Field')->assert(null), - fn(string $message) => expect($message)->toBe('Field must not be blank') + fn(string $message) => expect($message)->toBe('Field must not be blank'), )); test('Scenario #3', catchMessage( fn() => v::not(v::notBlank())->assert(1), - fn(string $message) => expect($message)->toBe('1 must be blank') + fn(string $message) => expect($message)->toBe('1 must be blank'), )); test('Scenario #4', catchFullMessage( fn() => v::notBlank()->assert(''), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must not be blank') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must not be blank'), )); test('Scenario #5', catchFullMessage( fn() => v::notBlank()->setName('Field')->assert(''), - fn(string $fullMessage) => expect($fullMessage)->toBe('- Field must not be blank') + fn(string $fullMessage) => expect($fullMessage)->toBe('- Field must not be blank'), )); test('Scenario #6', catchFullMessage( fn() => v::not(v::notBlank())->assert([1]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[1]` must be blank') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[1]` must be blank'), )); diff --git a/tests/feature/Rules/NotEmojiTest.php b/tests/feature/Rules/NotEmojiTest.php index da1f1e84..b314e6b7 100644 --- a/tests/feature/Rules/NotEmojiTest.php +++ b/tests/feature/Rules/NotEmojiTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::notEmoji()->assert('🍕'), - fn(string $message) => expect($message)->toBe('"🍕" must not contain an emoji') + fn(string $message) => expect($message)->toBe('"🍕" must not contain an emoji'), )); test('Scenario #2', catchMessage( fn() => v::not(v::notEmoji())->assert('AB'), - fn(string $message) => expect($message)->toBe('"AB" must contain an emoji') + fn(string $message) => expect($message)->toBe('"AB" must contain an emoji'), )); test('Scenario #3', catchFullMessage( fn() => v::notEmoji()->assert('🏄'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "🏄" must not contain an emoji') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "🏄" must not contain an emoji'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::notEmoji())->assert('YZ'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "YZ" must contain an emoji') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "YZ" must contain an emoji'), )); diff --git a/tests/feature/Rules/NotEmptyTest.php b/tests/feature/Rules/NotEmptyTest.php index 2324b11a..2bb401eb 100644 --- a/tests/feature/Rules/NotEmptyTest.php +++ b/tests/feature/Rules/NotEmptyTest.php @@ -9,30 +9,30 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::notEmpty()->assert(null), - fn(string $message) => expect($message)->toBe('`null` must not be empty') + fn(string $message) => expect($message)->toBe('`null` must not be empty'), )); test('Scenario #2', catchMessage( fn() => v::notEmpty()->setName('Field')->assert(null), - fn(string $message) => expect($message)->toBe('Field must not be empty') + fn(string $message) => expect($message)->toBe('Field must not be empty'), )); test('Scenario #3', catchMessage( fn() => v::not(v::notEmpty())->assert(1), - fn(string $message) => expect($message)->toBe('1 must be empty') + fn(string $message) => expect($message)->toBe('1 must be empty'), )); test('Scenario #4', catchFullMessage( fn() => v::notEmpty()->assert(''), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must not be empty') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must not be empty'), )); test('Scenario #5', catchFullMessage( fn() => v::notEmpty()->setName('Field')->assert(''), - fn(string $fullMessage) => expect($fullMessage)->toBe('- Field must not be empty') + fn(string $fullMessage) => expect($fullMessage)->toBe('- Field must not be empty'), )); test('Scenario #6', catchFullMessage( fn() => v::not(v::notEmpty())->assert([1]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[1]` must be empty') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[1]` must be empty'), )); diff --git a/tests/feature/Rules/NotUndefTest.php b/tests/feature/Rules/NotUndefTest.php index 1f2665dc..2ed8feca 100644 --- a/tests/feature/Rules/NotUndefTest.php +++ b/tests/feature/Rules/NotUndefTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::notUndef()->assert(null), - fn(string $message) => expect($message)->toBe('`null` must be defined') + fn(string $message) => expect($message)->toBe('`null` must be defined'), )); test('Scenario #2', catchMessage( fn() => v::not(v::notUndef())->assert(0), - fn(string $message) => expect($message)->toBe('0 must be undefined') + fn(string $message) => expect($message)->toBe('0 must be undefined'), )); test('Scenario #3', catchMessage( fn() => v::notUndef()->setName('Field')->assert(null), - fn(string $message) => expect($message)->toBe('Field must be defined') + fn(string $message) => expect($message)->toBe('Field must be defined'), )); test('Scenario #4', catchMessage( fn() => v::not(v::notUndef()->setName('Field'))->assert([]), - fn(string $message) => expect($message)->toBe('Field must be undefined') + fn(string $message) => expect($message)->toBe('Field must be undefined'), )); test('Scenario #5', catchFullMessage( fn() => v::notUndef()->assert(''), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must be defined') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "" must be defined'), )); test('Scenario #6', catchFullMessage( fn() => v::not(v::notUndef())->assert([]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[]` must be undefined') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[]` must be undefined'), )); test('Scenario #7', catchFullMessage( fn() => v::notUndef()->setName('Field')->assert(''), - fn(string $fullMessage) => expect($fullMessage)->toBe('- Field must be defined') + fn(string $fullMessage) => expect($fullMessage)->toBe('- Field must be defined'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::notUndef()->setName('Field'))->assert([]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- Field must be undefined') + fn(string $fullMessage) => expect($fullMessage)->toBe('- Field must be undefined'), )); diff --git a/tests/feature/Rules/NullOrTest.php b/tests/feature/Rules/NullOrTest.php index 268aa02e..337af72b 100644 --- a/tests/feature/Rules/NullOrTest.php +++ b/tests/feature/Rules/NullOrTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('1234 must contain only letters (a-z) or must be null') ->and($fullMessage)->toBe('- 1234 must contain only letters (a-z) or must be null') - ->and($messages)->toBe(['nullOrAlpha' => '1234 must contain only letters (a-z) or must be null']) + ->and($messages)->toBe(['nullOrAlpha' => '1234 must contain only letters (a-z) or must be null']), )); test('Inverted wrapper', catchAll( @@ -20,7 +20,7 @@ test('Inverted wrapper', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"alpha" must not contain letters (a-z) and must not be null') ->and($fullMessage)->toBe('- "alpha" must not contain letters (a-z) and must not be null') - ->and($messages)->toBe(['notNullOrAlpha' => '"alpha" must not contain letters (a-z) and must not be null']) + ->and($messages)->toBe(['notNullOrAlpha' => '"alpha" must not contain letters (a-z) and must not be null']), )); test('Inverted wrapped', catchAll( @@ -28,7 +28,7 @@ test('Inverted wrapped', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"alpha" must not contain letters (a-z) or must be null') ->and($fullMessage)->toBe('- "alpha" must not contain letters (a-z) or must be null') - ->and($messages)->toBe(['nullOrNotAlpha' => '"alpha" must not contain letters (a-z) or must be null']) + ->and($messages)->toBe(['nullOrNotAlpha' => '"alpha" must not contain letters (a-z) or must be null']), )); test('Inverted nullined', catchAll( @@ -36,7 +36,7 @@ test('Inverted nullined', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`null` must not contain letters (a-z) and must not be null') ->and($fullMessage)->toBe('- `null` must not contain letters (a-z) and must not be null') - ->and($messages)->toBe(['notNullOrAlpha' => '`null` must not contain letters (a-z) and must not be null']) + ->and($messages)->toBe(['notNullOrAlpha' => '`null` must not contain letters (a-z) and must not be null']), )); test('Inverted nullined, wrapped name', catchAll( @@ -44,7 +44,7 @@ test('Inverted nullined, wrapped name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must not contain letters (a-z) and must not be null') ->and($fullMessage)->toBe('- Wrapped must not contain letters (a-z) and must not be null') - ->and($messages)->toBe(['notNullOrAlpha' => 'Wrapped must not contain letters (a-z) and must not be null']) + ->and($messages)->toBe(['notNullOrAlpha' => 'Wrapped must not contain letters (a-z) and must not be null']), )); test('Inverted nullined, wrapper name', catchAll( @@ -52,7 +52,7 @@ test('Inverted nullined, wrapper name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must not contain letters (a-z) and must not be null') ->and($fullMessage)->toBe('- Wrapper must not contain letters (a-z) and must not be null') - ->and($messages)->toBe(['notNullOrAlpha' => 'Wrapper must not contain letters (a-z) and must not be null']) + ->and($messages)->toBe(['notNullOrAlpha' => 'Wrapper must not contain letters (a-z) and must not be null']), )); test('Inverted nullined, not name', catchAll( @@ -60,7 +60,7 @@ test('Inverted nullined, not name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not must not contain letters (a-z) and must not be null') ->and($fullMessage)->toBe('- Not must not contain letters (a-z) and must not be null') - ->and($messages)->toBe(['notNullOrAlpha' => 'Not must not contain letters (a-z) and must not be null']) + ->and($messages)->toBe(['notNullOrAlpha' => 'Not must not contain letters (a-z) and must not be null']), )); test('With template', catchAll( @@ -68,7 +68,7 @@ test('With template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Nine nimble numismatists near Naples') ->and($fullMessage)->toBe('- Nine nimble numismatists near Naples') - ->and($messages)->toBe(['nullOrAlpha' => 'Nine nimble numismatists near Naples']) + ->and($messages)->toBe(['nullOrAlpha' => 'Nine nimble numismatists near Naples']), )); test('With array template', catchAll( @@ -76,7 +76,7 @@ test('With array template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Next to nifty null notations') ->and($fullMessage)->toBe('- Next to nifty null notations') - ->and($messages)->toBe(['nullOrAlpha' => 'Next to nifty null notations']) + ->and($messages)->toBe(['nullOrAlpha' => 'Next to nifty null notations']), )); test('Inverted nullined with template', catchAll( @@ -84,7 +84,7 @@ test('Inverted nullined with template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Next to nifty null notations') ->and($fullMessage)->toBe('- Next to nifty null notations') - ->and($messages)->toBe(['notNullOrAlpha' => 'Next to nifty null notations']) + ->and($messages)->toBe(['notNullOrAlpha' => 'Next to nifty null notations']), )); test('Without adjacent result', catchAll( @@ -100,7 +100,7 @@ test('Without adjacent result', catchAll( '__root__' => '1234 must pass all the rules', 'nullOrAlpha' => '1234 must contain only letters (a-z) or must be null', 'nullOrStringType' => '1234 must be a string or must be null', - ]) + ]), )); test('Without adjacent result with templates', catchAll( @@ -119,5 +119,5 @@ test('Without adjacent result with templates', catchAll( '__root__' => '1234 must pass all the rules', 'nullOrAlpha' => 'Should be nul or alpha', 'nullOrStringType' => 'Should be nul or string type', - ]) + ]), )); diff --git a/tests/feature/Rules/NullTypeTest.php b/tests/feature/Rules/NullTypeTest.php index cfad8baf..6aed1902 100644 --- a/tests/feature/Rules/NullTypeTest.php +++ b/tests/feature/Rules/NullTypeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::nullType()->assert(''), - fn(string $message) => expect($message)->toBe('"" must be null') + fn(string $message) => expect($message)->toBe('"" must be null'), )); test('Scenario #2', catchMessage( fn() => v::not(v::nullType())->assert(null), - fn(string $message) => expect($message)->toBe('`null` must not be null') + fn(string $message) => expect($message)->toBe('`null` must not be null'), )); test('Scenario #3', catchFullMessage( fn() => v::nullType()->assert(false), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `false` must be null') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `false` must be null'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::nullType())->assert(null), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `null` must not be null') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `null` must not be null'), )); diff --git a/tests/feature/Rules/NumberTest.php b/tests/feature/Rules/NumberTest.php index 2c40abb7..3863d126 100644 --- a/tests/feature/Rules/NumberTest.php +++ b/tests/feature/Rules/NumberTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::number()->assert(acos(1.01)), - fn(string $message) => expect($message)->toBe('`NaN` must be a valid number') + fn(string $message) => expect($message)->toBe('`NaN` must be a valid number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::number())->assert(42), - fn(string $message) => expect($message)->toBe('42 must not be a number') + fn(string $message) => expect($message)->toBe('42 must not be a number'), )); test('Scenario #3', catchFullMessage( fn() => v::number()->assert(NAN), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `NaN` must be a valid number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `NaN` must be a valid number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::number())->assert(42), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 42 must not be a number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 42 must not be a number'), )); diff --git a/tests/feature/Rules/NumericValTest.php b/tests/feature/Rules/NumericValTest.php index a0c823bd..2a9bad05 100644 --- a/tests/feature/Rules/NumericValTest.php +++ b/tests/feature/Rules/NumericValTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::numericVal()->assert('a'), - fn(string $message) => expect($message)->toBe('"a" must be a numeric value') + fn(string $message) => expect($message)->toBe('"a" must be a numeric value'), )); test('Scenario #2', catchMessage( fn() => v::not(v::numericVal())->assert('1'), - fn(string $message) => expect($message)->toBe('"1" must not be a numeric value') + fn(string $message) => expect($message)->toBe('"1" must not be a numeric value'), )); test('Scenario #3', catchFullMessage( fn() => v::numericVal()->assert('a'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must be a numeric value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must be a numeric value'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::numericVal())->assert('1'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1" must not be a numeric value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1" must not be a numeric value'), )); diff --git a/tests/feature/Rules/ObjectTypeTest.php b/tests/feature/Rules/ObjectTypeTest.php index 587c9c57..736002c3 100644 --- a/tests/feature/Rules/ObjectTypeTest.php +++ b/tests/feature/Rules/ObjectTypeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::objectType()->assert([]), - fn(string $message) => expect($message)->toBe('`[]` must be an object') + fn(string $message) => expect($message)->toBe('`[]` must be an object'), )); test('Scenario #2', catchMessage( fn() => v::not(v::objectType())->assert(new stdClass()), - fn(string $message) => expect($message)->toBe('`stdClass {}` must not be an object') + fn(string $message) => expect($message)->toBe('`stdClass {}` must not be an object'), )); test('Scenario #3', catchFullMessage( fn() => v::objectType()->assert('test'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "test" must be an object') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "test" must be an object'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::objectType())->assert(new ArrayObject()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `ArrayObject { getArrayCopy() => [] }` must not be an object') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `ArrayObject { getArrayCopy() => [] }` must not be an object'), )); diff --git a/tests/feature/Rules/OddTest.php b/tests/feature/Rules/OddTest.php index 29780bad..0bb75c80 100644 --- a/tests/feature/Rules/OddTest.php +++ b/tests/feature/Rules/OddTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::odd()->assert(2), - fn(string $message) => expect($message)->toBe('2 must be an odd number') + fn(string $message) => expect($message)->toBe('2 must be an odd number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::odd())->assert(7), - fn(string $message) => expect($message)->toBe('7 must be an even number') + fn(string $message) => expect($message)->toBe('7 must be an even number'), )); test('Scenario #3', catchFullMessage( fn() => v::odd()->assert(2), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 2 must be an odd number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 2 must be an odd number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::odd())->assert(9), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 9 must be an even number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 9 must be an even number'), )); diff --git a/tests/feature/Rules/OneOfTest.php b/tests/feature/Rules/OneOfTest.php index 179d292a..952f07e2 100644 --- a/tests/feature/Rules/OneOfTest.php +++ b/tests/feature/Rules/OneOfTest.php @@ -20,7 +20,7 @@ test('Default: fail, fail', catchAll( '__root__' => '"string" must pass one of the rules', 'intType' => '"string" must be an integer', 'negative' => '"string" must be a negative number', - ]) + ]), )); test('Default: fail, pass, pass', catchAll( @@ -38,7 +38,7 @@ test('Default: fail, pass, pass', catchAll( 'intType' => '"string" must be an integer', 'stringType' => '"string" must be a string', 'alpha' => '"string" must contain only letters (a-z)', - ]) + ]), )); test('Default: pass, fail, pass', catchAll( @@ -56,7 +56,7 @@ test('Default: pass, fail, pass', catchAll( 'intType' => '"string" must be an integer', 'stringType' => '"string" must be a string', 'alpha' => '"string" must contain only letters (a-z)', - ]) + ]), )); test('Default: pass, pass, fail', catchAll( @@ -74,7 +74,7 @@ test('Default: pass, pass, fail', catchAll( 'intType' => '"string" must be an integer', 'stringType' => '"string" must be a string', 'alpha' => '"string" must contain only letters (a-z)', - ]) + ]), )); test('Inverted: fail, pass', catchAll( @@ -82,9 +82,7 @@ test('Inverted: fail, pass', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('-1 must not be an integer') ->and($fullMessage)->toBe('- -1 must not be an integer') - ->and($messages)->toBe([ - 'intType' => '-1 must not be an integer', - ]) + ->and($messages)->toBe(['intType' => '-1 must not be an integer']), )); test('Inverted: fail, fail, pass', catchAll( @@ -92,7 +90,5 @@ test('Inverted: fail, fail, pass', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('-1 must not be a negative number') ->and($fullMessage)->toBe('- -1 must not be a negative number') - ->and($messages)->toBe([ - 'negative' => '-1 must not be a negative number', - ]) + ->and($messages)->toBe(['negative' => '-1 must not be a negative number']), )); diff --git a/tests/feature/Rules/PerfectSquareTest.php b/tests/feature/Rules/PerfectSquareTest.php index 3bd162d5..59933d9d 100644 --- a/tests/feature/Rules/PerfectSquareTest.php +++ b/tests/feature/Rules/PerfectSquareTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::perfectSquare()->assert(250), - fn(string $message) => expect($message)->toBe('250 must be a perfect square number') + fn(string $message) => expect($message)->toBe('250 must be a perfect square number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::perfectSquare())->assert(9), - fn(string $message) => expect($message)->toBe('9 must not be a perfect square number') + fn(string $message) => expect($message)->toBe('9 must not be a perfect square number'), )); test('Scenario #3', catchFullMessage( fn() => v::perfectSquare()->assert(7), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 7 must be a perfect square number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 7 must be a perfect square number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::perfectSquare())->assert(400), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 400 must not be a perfect square number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 400 must not be a perfect square number'), )); diff --git a/tests/feature/Rules/PeselTest.php b/tests/feature/Rules/PeselTest.php index 3a1ef03c..6d6c73c1 100644 --- a/tests/feature/Rules/PeselTest.php +++ b/tests/feature/Rules/PeselTest.php @@ -11,20 +11,20 @@ require_once 'vendor/autoload.php'; test('Scenario #1', catchMessage( fn() => v::pesel()->assert('21120209251'), - fn(string $message) => expect($message)->toBe('"21120209251" must be a valid PESEL') + fn(string $message) => expect($message)->toBe('"21120209251" must be a valid PESEL'), )); test('Scenario #2', catchMessage( fn() => v::not(v::pesel())->assert('21120209256'), - fn(string $message) => expect($message)->toBe('"21120209256" must not be a valid PESEL') + fn(string $message) => expect($message)->toBe('"21120209256" must not be a valid PESEL'), )); test('Scenario #3', catchFullMessage( fn() => v::pesel()->assert('21120209251'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "21120209251" must be a valid PESEL') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "21120209251" must be a valid PESEL'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::pesel())->assert('21120209256'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "21120209256" must not be a valid PESEL') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "21120209256" must not be a valid PESEL'), )); diff --git a/tests/feature/Rules/PhoneTest.php b/tests/feature/Rules/PhoneTest.php index d3a48fec..be63200c 100644 --- a/tests/feature/Rules/PhoneTest.php +++ b/tests/feature/Rules/PhoneTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"123" must be a valid telephone number') ->and($fullMessage)->toBe('- "123" must be a valid telephone number') - ->and($messages)->toBe(['phone' => '"123" must be a valid telephone number']) + ->and($messages)->toBe(['phone' => '"123" must be a valid telephone number']), )); test('Country-specific', catchAll( @@ -20,7 +20,7 @@ test('Country-specific', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"+1 650 253 00 00" must be a valid telephone number for country Brazil') ->and($fullMessage)->toBe('- "+1 650 253 00 00" must be a valid telephone number for country Brazil') - ->and($messages)->toBe(['phone' => '"+1 650 253 00 00" must be a valid telephone number for country Brazil']) + ->and($messages)->toBe(['phone' => '"+1 650 253 00 00" must be a valid telephone number for country Brazil']), )); test('Inverted', catchAll( @@ -28,7 +28,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"+55 11 91111 1111" must not be a valid telephone number') ->and($fullMessage)->toBe('- "+55 11 91111 1111" must not be a valid telephone number') - ->and($messages)->toBe(['notPhone' => '"+55 11 91111 1111" must not be a valid telephone number']) + ->and($messages)->toBe(['notPhone' => '"+55 11 91111 1111" must not be a valid telephone number']), )); test('Default with name', catchAll( @@ -36,7 +36,7 @@ test('Default with name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Phone must be a valid telephone number') ->and($fullMessage)->toBe('- Phone must be a valid telephone number') - ->and($messages)->toBe(['phone' => 'Phone must be a valid telephone number']) + ->and($messages)->toBe(['phone' => 'Phone must be a valid telephone number']), )); test('Country-specific with name', catchAll( @@ -44,5 +44,5 @@ test('Country-specific with name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Phone must be a valid telephone number for country United States') ->and($fullMessage)->toBe('- Phone must be a valid telephone number for country United States') - ->and($messages)->toBe(['phone' => 'Phone must be a valid telephone number for country United States']) + ->and($messages)->toBe(['phone' => 'Phone must be a valid telephone number for country United States']), )); diff --git a/tests/feature/Rules/PhplabelTest.php b/tests/feature/Rules/PhplabelTest.php index 6a301b04..6f4017c4 100644 --- a/tests/feature/Rules/PhplabelTest.php +++ b/tests/feature/Rules/PhplabelTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::phpLabel()->assert('f o o'), - fn(string $message) => expect($message)->toBe('"f o o" must be a valid PHP label') + fn(string $message) => expect($message)->toBe('"f o o" must be a valid PHP label'), )); test('Scenario #2', catchMessage( fn() => v::not(v::phpLabel())->assert('correctOne'), - fn(string $message) => expect($message)->toBe('"correctOne" must not be a valid PHP label') + fn(string $message) => expect($message)->toBe('"correctOne" must not be a valid PHP label'), )); test('Scenario #3', catchFullMessage( fn() => v::phpLabel()->assert('0wner'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "0wner" must be a valid PHP label') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "0wner" must be a valid PHP label'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::phpLabel())->assert('Respect'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "Respect" must not be a valid PHP label') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "Respect" must not be a valid PHP label'), )); diff --git a/tests/feature/Rules/PisTest.php b/tests/feature/Rules/PisTest.php index a59e6edf..bfcab318 100644 --- a/tests/feature/Rules/PisTest.php +++ b/tests/feature/Rules/PisTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::pis()->assert('this thing'), - fn(string $message) => expect($message)->toBe('"this thing" must be a valid PIS number') + fn(string $message) => expect($message)->toBe('"this thing" must be a valid PIS number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::pis())->assert('120.6671.406-4'), - fn(string $message) => expect($message)->toBe('"120.6671.406-4" must not be a valid PIS number') + fn(string $message) => expect($message)->toBe('"120.6671.406-4" must not be a valid PIS number'), )); test('Scenario #3', catchFullMessage( fn() => v::pis()->assert('your mother'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "your mother" must be a valid PIS number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "your mother" must be a valid PIS number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::pis())->assert('120.9378.174-5'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "120.9378.174-5" must not be a valid PIS number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "120.9378.174-5" must not be a valid PIS number'), )); diff --git a/tests/feature/Rules/PolishIdCardTest.php b/tests/feature/Rules/PolishIdCardTest.php index c5a71972..181a83f1 100644 --- a/tests/feature/Rules/PolishIdCardTest.php +++ b/tests/feature/Rules/PolishIdCardTest.php @@ -11,20 +11,20 @@ require_once 'vendor/autoload.php'; test('Scenario #1', catchMessage( fn() => v::polishIdCard()->assert('AYE205411'), - fn(string $message) => expect($message)->toBe('"AYE205411" must be a valid Polish Identity Card number') + fn(string $message) => expect($message)->toBe('"AYE205411" must be a valid Polish Identity Card number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::polishIdCard())->assert('AYE205410'), - fn(string $message) => expect($message)->toBe('"AYE205410" must not be a valid Polish Identity Card number') + fn(string $message) => expect($message)->toBe('"AYE205410" must not be a valid Polish Identity Card number'), )); test('Scenario #3', catchFullMessage( fn() => v::polishIdCard()->assert('AYE205411'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "AYE205411" must be a valid Polish Identity Card number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "AYE205411" must be a valid Polish Identity Card number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::polishIdCard())->assert('AYE205410'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "AYE205410" must not be a valid Polish Identity Card number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "AYE205410" must not be a valid Polish Identity Card number'), )); diff --git a/tests/feature/Rules/PositiveTest.php b/tests/feature/Rules/PositiveTest.php index 022925dc..9655ed75 100644 --- a/tests/feature/Rules/PositiveTest.php +++ b/tests/feature/Rules/PositiveTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::positive()->assert(-10), - fn(string $message) => expect($message)->toBe('-10 must be a positive number') + fn(string $message) => expect($message)->toBe('-10 must be a positive number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::positive())->assert(16), - fn(string $message) => expect($message)->toBe('16 must not be a positive number') + fn(string $message) => expect($message)->toBe('16 must not be a positive number'), )); test('Scenario #3', catchFullMessage( fn() => v::positive()->assert('a'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must be a positive number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "a" must be a positive number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::positive())->assert('165'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "165" must not be a positive number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "165" must not be a positive number'), )); diff --git a/tests/feature/Rules/PostalCodeTest.php b/tests/feature/Rules/PostalCodeTest.php index 84b3c0af..ae48828a 100644 --- a/tests/feature/Rules/PostalCodeTest.php +++ b/tests/feature/Rules/PostalCodeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::postalCode('BR')->assert('1057BV'), - fn(string $message) => expect($message)->toBe('"1057BV" must be a valid postal code on "BR"') + fn(string $message) => expect($message)->toBe('"1057BV" must be a valid postal code on "BR"'), )); test('Scenario #2', catchMessage( fn() => v::not(v::postalCode('NL'))->assert('1057BV'), - fn(string $message) => expect($message)->toBe('"1057BV" must not be a valid postal code on "NL"') + fn(string $message) => expect($message)->toBe('"1057BV" must not be a valid postal code on "NL"'), )); test('Scenario #3', catchFullMessage( fn() => v::postalCode('BR')->assert('1057BV'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1057BV" must be a valid postal code on "BR"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1057BV" must be a valid postal code on "BR"'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::postalCode('NL'))->assert('1057BV'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1057BV" must not be a valid postal code on "NL"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1057BV" must not be a valid postal code on "NL"'), )); diff --git a/tests/feature/Rules/PrimeNumberTest.php b/tests/feature/Rules/PrimeNumberTest.php index e735d425..25f20b34 100644 --- a/tests/feature/Rules/PrimeNumberTest.php +++ b/tests/feature/Rules/PrimeNumberTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::primeNumber()->assert(10), - fn(string $message) => expect($message)->toBe('10 must be a prime number') + fn(string $message) => expect($message)->toBe('10 must be a prime number'), )); test('Scenario #2', catchMessage( fn() => v::not(v::primeNumber())->assert(3), - fn(string $message) => expect($message)->toBe('3 must not be a prime number') + fn(string $message) => expect($message)->toBe('3 must not be a prime number'), )); test('Scenario #3', catchFullMessage( fn() => v::primeNumber()->assert('Foo'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "Foo" must be a prime number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "Foo" must be a prime number'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::primeNumber())->assert('+7'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "+7" must not be a prime number') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "+7" must not be a prime number'), )); diff --git a/tests/feature/Rules/PrintableTest.php b/tests/feature/Rules/PrintableTest.php index 2dfb2d71..e0469df9 100644 --- a/tests/feature/Rules/PrintableTest.php +++ b/tests/feature/Rules/PrintableTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::printable()->assert(''), - fn(string $message) => expect($message)->toBe('"" must contain only printable characters') + fn(string $message) => expect($message)->toBe('"" must contain only printable characters'), )); test('Scenario #2', catchMessage( fn() => v::not(v::printable())->assert('abc'), - fn(string $message) => expect($message)->toBe('"abc" must not contain printable characters') + fn(string $message) => expect($message)->toBe('"abc" must not contain printable characters'), )); test('Scenario #3', catchFullMessage( fn() => v::printable()->assert('foo' . chr(10) . 'bar'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "foo\\nbar" must contain only printable characters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "foo\\nbar" must contain only printable characters'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::printable())->assert('$%asd'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "$%asd" must not contain printable characters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "$%asd" must not contain printable characters'), )); diff --git a/tests/feature/Rules/PropertyExistsTest.php b/tests/feature/Rules/PropertyExistsTest.php index 404225f1..cc935f8f 100644 --- a/tests/feature/Rules/PropertyExistsTest.php +++ b/tests/feature/Rules/PropertyExistsTest.php @@ -12,7 +12,7 @@ test('Default mode', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be present') ->and($fullMessage)->toBe('- `.foo` must be present') - ->and($messages)->toBe(['foo' => '`.foo` must be present']) + ->and($messages)->toBe(['foo' => '`.foo` must be present']), )); test('Inverted mode', catchAll( @@ -20,7 +20,7 @@ test('Inverted mode', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must not be present') ->and($fullMessage)->toBe('- `.foo` must not be present') - ->and($messages)->toBe(['foo' => '`.foo` must not be present']) + ->and($messages)->toBe(['foo' => '`.foo` must not be present']), )); test('Custom name', catchAll( @@ -28,7 +28,7 @@ test('Custom name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Custom name must be present') ->and($fullMessage)->toBe('- Custom name must be present') - ->and($messages)->toBe(['foo' => 'Custom name must be present']) + ->and($messages)->toBe(['foo' => 'Custom name must be present']), )); test('Custom template', catchAll( @@ -36,5 +36,5 @@ test('Custom template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Custom template for `.foo`') ->and($fullMessage)->toBe('- Custom template for `.foo`') - ->and($messages)->toBe(['foo' => 'Custom template for `.foo`']) + ->and($messages)->toBe(['foo' => 'Custom template for `.foo`']), )); diff --git a/tests/feature/Rules/PropertyOptionalTest.php b/tests/feature/Rules/PropertyOptionalTest.php index 237f1813..45a90297 100644 --- a/tests/feature/Rules/PropertyOptionalTest.php +++ b/tests/feature/Rules/PropertyOptionalTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be an integer') ->and($fullMessage)->toBe('- `.foo` must be an integer') - ->and($messages)->toBe(['foo' => '`.foo` must be an integer']) + ->and($messages)->toBe(['foo' => '`.foo` must be an integer']), )); test('Inverted', catchAll( @@ -20,7 +20,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must not be an integer') ->and($fullMessage)->toBe('- `.foo` must not be an integer') - ->and($messages)->toBe(['foo' => '`.foo` must not be an integer']) + ->and($messages)->toBe(['foo' => '`.foo` must not be an integer']), )); test('Inverted with missing property', catchAll( @@ -28,7 +28,7 @@ test('Inverted with missing property', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be present') ->and($fullMessage)->toBe('- `.foo` must be present') - ->and($messages)->toBe(['foo' => '`.foo` must be present']) + ->and($messages)->toBe(['foo' => '`.foo` must be present']), )); test('With wrapped name, default', catchAll( @@ -36,7 +36,7 @@ test('With wrapped name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must be an integer') ->and($fullMessage)->toBe('- Wrapped must be an integer') - ->and($messages)->toBe(['foo' => 'Wrapped must be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapped must be an integer']), )); test('With wrapped name, inverted', catchAll( @@ -44,7 +44,7 @@ test('With wrapped name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must not be an integer') ->and($fullMessage)->toBe('- Wrapped must not be an integer') - ->and($messages)->toBe(['foo' => 'Wrapped must not be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapped must not be an integer']), )); test('With wrapper name, default', catchAll( @@ -52,7 +52,7 @@ test('With wrapper name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must be an integer') ->and($fullMessage)->toBe('- Wrapper must be an integer') - ->and($messages)->toBe(['foo' => 'Wrapper must be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapper must be an integer']), )); test('With wrapper name, inverted', catchAll( @@ -60,7 +60,7 @@ test('With wrapper name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must not be an integer') ->and($fullMessage)->toBe('- Wrapper must not be an integer') - ->and($messages)->toBe(['foo' => 'Wrapper must not be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapper must not be an integer']), )); test('With "Not" name, inverted', catchAll( @@ -68,7 +68,7 @@ test('With "Not" name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not must not be an integer') ->and($fullMessage)->toBe('- Not must not be an integer') - ->and($messages)->toBe(['foo' => 'Not must not be an integer']) + ->and($messages)->toBe(['foo' => 'Not must not be an integer']), )); test('With template, default', catchAll( @@ -77,7 +77,7 @@ test('With template, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Proper property planners plan precise property plots') ->and($fullMessage)->toBe('- Proper property planners plan precise property plots') - ->and($messages)->toBe(['foo' => 'Proper property planners plan precise property plots']) + ->and($messages)->toBe(['foo' => 'Proper property planners plan precise property plots']), )); test('With template, inverted', catchAll( @@ -86,5 +86,5 @@ test('With template, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not proving prudent property planning promotes prosperity') ->and($fullMessage)->toBe('- Not proving prudent property planning promotes prosperity') - ->and($messages)->toBe(['foo' => 'Not proving prudent property planning promotes prosperity']) + ->and($messages)->toBe(['foo' => 'Not proving prudent property planning promotes prosperity']), )); diff --git a/tests/feature/Rules/PropertyTest.php b/tests/feature/Rules/PropertyTest.php index 6feb57b3..2f5657be 100644 --- a/tests/feature/Rules/PropertyTest.php +++ b/tests/feature/Rules/PropertyTest.php @@ -12,7 +12,7 @@ test('Missing property', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be present') ->and($fullMessage)->toBe('- `.foo` must be present') - ->and($messages)->toBe(['foo' => '`.foo` must be present']) + ->and($messages)->toBe(['foo' => '`.foo` must be present']), )); test('Default', catchAll( @@ -20,7 +20,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be an integer') ->and($fullMessage)->toBe('- `.foo` must be an integer') - ->and($messages)->toBe(['foo' => '`.foo` must be an integer']) + ->and($messages)->toBe(['foo' => '`.foo` must be an integer']), )); test('Inverted', catchAll( @@ -28,7 +28,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must not be an integer') ->and($fullMessage)->toBe('- `.foo` must not be an integer') - ->and($messages)->toBe(['foo' => '`.foo` must not be an integer']) + ->and($messages)->toBe(['foo' => '`.foo` must not be an integer']), )); test('Double-inverted with missing property', catchAll( @@ -36,7 +36,7 @@ test('Double-inverted with missing property', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be present') ->and($fullMessage)->toBe('- `.foo` must be present') - ->and($messages)->toBe(['foo' => '`.foo` must be present']) + ->and($messages)->toBe(['foo' => '`.foo` must be present']), )); test('With wrapped name, missing property', catchAll( @@ -44,7 +44,7 @@ test('With wrapped name, missing property', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must be present') ->and($fullMessage)->toBe('- Wrapped must be present') - ->and($messages)->toBe(['foo' => 'Wrapped must be present']) + ->and($messages)->toBe(['foo' => 'Wrapped must be present']), )); test('With wrapped name, default', catchAll( @@ -52,7 +52,7 @@ test('With wrapped name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must be an integer') ->and($fullMessage)->toBe('- Wrapped must be an integer') - ->and($messages)->toBe(['foo' => 'Wrapped must be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapped must be an integer']), )); test('With wrapped name, inverted', catchAll( @@ -64,7 +64,7 @@ test('With wrapped name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must not be an integer') ->and($fullMessage)->toBe('- Wrapped must not be an integer') - ->and($messages)->toBe(['foo' => 'Wrapped must not be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapped must not be an integer']), )); test('With wrapper name, default', catchAll( @@ -72,7 +72,7 @@ test('With wrapper name, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must be an integer') ->and($fullMessage)->toBe('- Wrapper must be an integer') - ->and($messages)->toBe(['foo' => 'Wrapper must be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapper must be an integer']), )); test('With wrapper name, missing property', catchAll( @@ -80,7 +80,7 @@ test('With wrapper name, missing property', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must be present') ->and($fullMessage)->toBe('- Wrapper must be present') - ->and($messages)->toBe(['foo' => 'Wrapper must be present']) + ->and($messages)->toBe(['foo' => 'Wrapper must be present']), )); test('With wrapper name, inverted', catchAll( @@ -89,7 +89,7 @@ test('With wrapper name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must not be an integer') ->and($fullMessage)->toBe('- Wrapper must not be an integer') - ->and($messages)->toBe(['foo' => 'Wrapper must not be an integer']) + ->and($messages)->toBe(['foo' => 'Wrapper must not be an integer']), )); test('With "Not" name, inverted', catchAll( @@ -97,7 +97,7 @@ test('With "Not" name, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not must not be an integer') ->and($fullMessage)->toBe('- Not must not be an integer') - ->and($messages)->toBe(['foo' => 'Not must not be an integer']) + ->and($messages)->toBe(['foo' => 'Not must not be an integer']), )); test('With template, default', catchAll( @@ -106,7 +106,7 @@ test('With template, default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Particularly precautions perplexing property') ->and($fullMessage)->toBe('- Particularly precautions perplexing property') - ->and($messages)->toBe(['foo' => 'Particularly precautions perplexing property']) + ->and($messages)->toBe(['foo' => 'Particularly precautions perplexing property']), )); test('With template, inverted', catchAll( @@ -115,5 +115,5 @@ test('With template, inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not a prompt prospect of a particularly primitive property') ->and($fullMessage)->toBe('- Not a prompt prospect of a particularly primitive property') - ->and($messages)->toBe(['foo' => 'Not a prompt prospect of a particularly primitive property']) + ->and($messages)->toBe(['foo' => 'Not a prompt prospect of a particularly primitive property']), )); diff --git a/tests/feature/Rules/PunctTest.php b/tests/feature/Rules/PunctTest.php index 4137a7ad..210e5714 100644 --- a/tests/feature/Rules/PunctTest.php +++ b/tests/feature/Rules/PunctTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::punct()->assert('a'), - fn(string $message) => expect($message)->toBe('"a" must contain only punctuation characters') + fn(string $message) => expect($message)->toBe('"a" must contain only punctuation characters'), )); test('Scenario #2', catchMessage( fn() => v::punct('c')->assert('b'), - fn(string $message) => expect($message)->toBe('"b" must contain only punctuation characters and "c"') + fn(string $message) => expect($message)->toBe('"b" must contain only punctuation characters and "c"'), )); test('Scenario #3', catchMessage( fn() => v::not(v::punct())->assert('.'), - fn(string $message) => expect($message)->toBe('"." must not contain punctuation characters') + fn(string $message) => expect($message)->toBe('"." must not contain punctuation characters'), )); test('Scenario #4', catchMessage( fn() => v::not(v::punct('d'))->assert('?'), - fn(string $message) => expect($message)->toBe('"?" must not contain punctuation characters or "d"') + fn(string $message) => expect($message)->toBe('"?" must not contain punctuation characters or "d"'), )); test('Scenario #5', catchFullMessage( fn() => v::punct()->assert('e'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "e" must contain only punctuation characters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "e" must contain only punctuation characters'), )); test('Scenario #6', catchFullMessage( fn() => v::punct('f')->assert('g'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "g" must contain only punctuation characters and "f"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "g" must contain only punctuation characters and "f"'), )); test('Scenario #7', catchFullMessage( fn() => v::not(v::punct())->assert('!'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "!" must not contain punctuation characters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "!" must not contain punctuation characters'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::punct('h'))->assert(';'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- ";" must not contain punctuation characters or "h"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- ";" must not contain punctuation characters or "h"'), )); diff --git a/tests/feature/Rules/ReadableTest.php b/tests/feature/Rules/ReadableTest.php index 84787edc..efae3c69 100644 --- a/tests/feature/Rules/ReadableTest.php +++ b/tests/feature/Rules/ReadableTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::readable()->assert('tests/fixtures/invalid-image.jpg'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/invalid-image.jpg" must be readable') + fn(string $message) => expect($message)->toBe('"tests/fixtures/invalid-image.jpg" must be readable'), )); test('Scenario #2', catchMessage( fn() => v::not(v::readable())->assert('tests/fixtures/valid-image.png'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.png" must not be readable') + fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.png" must not be readable'), )); test('Scenario #3', catchFullMessage( fn() => v::readable()->assert(new stdClass()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be readable') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be readable'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::readable())->assert('tests/fixtures/valid-image.png'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/valid-image.png" must not be readable') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/valid-image.png" must not be readable'), )); diff --git a/tests/feature/Rules/RegexTest.php b/tests/feature/Rules/RegexTest.php index 5c06098a..75bc2d61 100644 --- a/tests/feature/Rules/RegexTest.php +++ b/tests/feature/Rules/RegexTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::regex('/^w+$/')->assert('w poiur'), - fn(string $message) => expect($message)->toBe('"w poiur" must match the pattern `/^w+$/`') + fn(string $message) => expect($message)->toBe('"w poiur" must match the pattern `/^w+$/`'), )); test('Scenario #2', catchMessage( fn() => v::not(v::regex('/^[a-z]+$/'))->assert('wpoiur'), - fn(string $message) => expect($message)->toBe('"wpoiur" must not match the pattern `/^[a-z]+$/`') + fn(string $message) => expect($message)->toBe('"wpoiur" must not match the pattern `/^[a-z]+$/`'), )); test('Scenario #3', catchFullMessage( fn() => v::regex('/^w+$/')->assert(new stdClass()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must match the pattern `/^w+$/`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must match the pattern `/^w+$/`'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::regex('/^[a-z]+$/i'))->assert('wPoiur'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "wPoiur" must not match the pattern `/^[a-z]+$/i`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "wPoiur" must not match the pattern `/^[a-z]+$/i`'), )); diff --git a/tests/feature/Rules/ResourceTypeTest.php b/tests/feature/Rules/ResourceTypeTest.php index 2e81a527..9ccb52a6 100644 --- a/tests/feature/Rules/ResourceTypeTest.php +++ b/tests/feature/Rules/ResourceTypeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::resourceType()->assert('test'), - fn(string $message) => expect($message)->toBe('"test" must be a resource') + fn(string $message) => expect($message)->toBe('"test" must be a resource'), )); test('Scenario #2', catchMessage( fn() => v::not(v::resourceType())->assert(tmpfile()), - fn(string $message) => expect($message)->toBe('`resource ` must not be a resource') + fn(string $message) => expect($message)->toBe('`resource ` must not be a resource'), )); test('Scenario #3', catchFullMessage( fn() => v::resourceType()->assert([]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[]` must be a resource') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[]` must be a resource'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::resourceType())->assert(tmpfile()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `resource ` must not be a resource') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `resource ` must not be a resource'), )); diff --git a/tests/feature/Rules/RomanTest.php b/tests/feature/Rules/RomanTest.php index de93ca66..5197d93c 100644 --- a/tests/feature/Rules/RomanTest.php +++ b/tests/feature/Rules/RomanTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::roman()->assert(1234), - fn(string $message) => expect($message)->toBe('1234 must be a valid Roman numeral') + fn(string $message) => expect($message)->toBe('1234 must be a valid Roman numeral'), )); test('Scenario #2', catchMessage( fn() => v::not(v::roman())->assert('XL'), - fn(string $message) => expect($message)->toBe('"XL" must not be a valid Roman numeral') + fn(string $message) => expect($message)->toBe('"XL" must not be a valid Roman numeral'), )); test('Scenario #3', catchFullMessage( fn() => v::roman()->assert('e2'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "e2" must be a valid Roman numeral') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "e2" must be a valid Roman numeral'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::roman())->assert('IV'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "IV" must not be a valid Roman numeral') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "IV" must not be a valid Roman numeral'), )); diff --git a/tests/feature/Rules/ScalarValTest.php b/tests/feature/Rules/ScalarValTest.php index 72868989..ee67a76b 100644 --- a/tests/feature/Rules/ScalarValTest.php +++ b/tests/feature/Rules/ScalarValTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::scalarVal()->assert([]), - fn(string $message) => expect($message)->toBe('`[]` must be a scalar value') + fn(string $message) => expect($message)->toBe('`[]` must be a scalar value'), )); test('Scenario #2', catchMessage( fn() => v::not(v::scalarVal())->assert(true), - fn(string $message) => expect($message)->toBe('`true` must not be a scalar value') + fn(string $message) => expect($message)->toBe('`true` must not be a scalar value'), )); test('Scenario #3', catchFullMessage( fn() => v::scalarVal()->assert(new stdClass()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be a scalar value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be a scalar value'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::scalarVal())->assert(42), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 42 must not be a scalar value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 42 must not be a scalar value'), )); diff --git a/tests/feature/Rules/SizeTest.php b/tests/feature/Rules/SizeTest.php index fccfbba2..e1926cfd 100644 --- a/tests/feature/Rules/SizeTest.php +++ b/tests/feature/Rules/SizeTest.php @@ -27,7 +27,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The size in kilobytes of "vfs://root/2kb.txt" must be less than 2') ->and($fullMessage)->toBe('- The size in kilobytes of "vfs://root/2kb.txt" must be less than 2') - ->and($messages)->toBe(['sizeLessThan' => 'The size in kilobytes of "vfs://root/2kb.txt" must be less than 2']) + ->and($messages)->toBe(['sizeLessThan' => 'The size in kilobytes of "vfs://root/2kb.txt" must be less than 2']), )); test('Wrong type', catchAll( @@ -35,7 +35,7 @@ test('Wrong type', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`stdClass {}` must be a filename or an instance of SplFileInfo or a PSR-7 interface') ->and($fullMessage)->toBe('- `stdClass {}` must be a filename or an instance of SplFileInfo or a PSR-7 interface') - ->and($messages)->toBe(['sizeLessThan' => '`stdClass {}` must be a filename or an instance of SplFileInfo or a PSR-7 interface']) + ->and($messages)->toBe(['sizeLessThan' => '`stdClass {}` must be a filename or an instance of SplFileInfo or a PSR-7 interface']), )); test('Inverted', catchAll( @@ -43,7 +43,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The size in megabytes of "vfs://root/3mb.txt" must not be equal to 3') ->and($fullMessage)->toBe('- The size in megabytes of "vfs://root/3mb.txt" must not be equal to 3') - ->and($messages)->toBe(['sizeNotEquals' => 'The size in megabytes of "vfs://root/3mb.txt" must not be equal to 3']) + ->and($messages)->toBe(['sizeNotEquals' => 'The size in megabytes of "vfs://root/3mb.txt" must not be equal to 3']), )); test('Wrapped with name', catchAll( @@ -51,7 +51,7 @@ test('Wrapped with name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The size in kilobytes of Wrapped must be less than 2') ->and($fullMessage)->toBe('- The size in kilobytes of Wrapped must be less than 2') - ->and($messages)->toBe(['sizeLessThan' => 'The size in kilobytes of Wrapped must be less than 2']) + ->and($messages)->toBe(['sizeLessThan' => 'The size in kilobytes of Wrapped must be less than 2']), )); test('Wrapper with name', catchAll( @@ -59,7 +59,7 @@ test('Wrapper with name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The size in kilobytes of Wrapper must be less than 2') ->and($fullMessage)->toBe('- The size in kilobytes of Wrapper must be less than 2') - ->and($messages)->toBe(['sizeLessThan' => 'The size in kilobytes of Wrapper must be less than 2']) + ->and($messages)->toBe(['sizeLessThan' => 'The size in kilobytes of Wrapper must be less than 2']), )); test('Chained wrapped rule', catchAll( @@ -75,5 +75,5 @@ test('Chained wrapped rule', catchAll( '__root__' => '"vfs://root/2kb.txt" must pass all the rules', 'sizeBetween' => 'The size in kilobytes of "vfs://root/2kb.txt" must be between 5 and 7', 'sizeOdd' => 'The size in kilobytes of "vfs://root/2kb.txt" must be an odd number', - ]) + ]), )); diff --git a/tests/feature/Rules/SlugTest.php b/tests/feature/Rules/SlugTest.php index 1331c16f..81c7b3b2 100644 --- a/tests/feature/Rules/SlugTest.php +++ b/tests/feature/Rules/SlugTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::slug()->assert('my-Slug'), - fn(string $message) => expect($message)->toBe('"my-Slug" must be a valid slug') + fn(string $message) => expect($message)->toBe('"my-Slug" must be a valid slug'), )); test('Scenario #2', catchMessage( fn() => v::not(v::slug())->assert('my-slug'), - fn(string $message) => expect($message)->toBe('"my-slug" must not be a valid slug') + fn(string $message) => expect($message)->toBe('"my-slug" must not be a valid slug'), )); test('Scenario #3', catchFullMessage( fn() => v::slug()->assert('my-Slug'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "my-Slug" must be a valid slug') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "my-Slug" must be a valid slug'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::slug())->assert('my-slug'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "my-slug" must not be a valid slug') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "my-slug" must not be a valid slug'), )); diff --git a/tests/feature/Rules/SortedTest.php b/tests/feature/Rules/SortedTest.php index 21ef5011..e2d4fad6 100644 --- a/tests/feature/Rules/SortedTest.php +++ b/tests/feature/Rules/SortedTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::sorted('ASC')->assert([1, 3, 2]), - fn(string $message) => expect($message)->toBe('`[1, 3, 2]` must be sorted in ascending order') + fn(string $message) => expect($message)->toBe('`[1, 3, 2]` must be sorted in ascending order'), )); test('Scenario #2', catchMessage( fn() => v::sorted('DESC')->assert([1, 2, 3]), - fn(string $message) => expect($message)->toBe('`[1, 2, 3]` must be sorted in descending order') + fn(string $message) => expect($message)->toBe('`[1, 2, 3]` must be sorted in descending order'), )); test('Scenario #3', catchMessage( fn() => v::not(v::sorted('ASC'))->assert([1, 2, 3]), - fn(string $message) => expect($message)->toBe('`[1, 2, 3]` must not be sorted in ascending order') + fn(string $message) => expect($message)->toBe('`[1, 2, 3]` must not be sorted in ascending order'), )); test('Scenario #4', catchMessage( fn() => v::not(v::sorted('DESC'))->assert([3, 2, 1]), - fn(string $message) => expect($message)->toBe('`[3, 2, 1]` must not be sorted in descending order') + fn(string $message) => expect($message)->toBe('`[3, 2, 1]` must not be sorted in descending order'), )); test('Scenario #5', catchFullMessage( fn() => v::sorted('ASC')->assert([3, 2, 1]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[3, 2, 1]` must be sorted in ascending order') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[3, 2, 1]` must be sorted in ascending order'), )); test('Scenario #6', catchFullMessage( fn() => v::sorted('DESC')->assert([1, 2, 3]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[1, 2, 3]` must be sorted in descending order') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[1, 2, 3]` must be sorted in descending order'), )); test('Scenario #7', catchFullMessage( fn() => v::not(v::sorted('ASC'))->assert([1, 2, 3]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[1, 2, 3]` must not be sorted in ascending order') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[1, 2, 3]` must not be sorted in ascending order'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::sorted('DESC'))->assert([3, 2, 1]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[3, 2, 1]` must not be sorted in descending order') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[3, 2, 1]` must not be sorted in descending order'), )); diff --git a/tests/feature/Rules/SpaceTest.php b/tests/feature/Rules/SpaceTest.php index 7239e8dc..083c8d87 100644 --- a/tests/feature/Rules/SpaceTest.php +++ b/tests/feature/Rules/SpaceTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::space()->assert('ab'), - fn(string $message) => expect($message)->toBe('"ab" must contain only space characters') + fn(string $message) => expect($message)->toBe('"ab" must contain only space characters'), )); test('Scenario #2', catchMessage( fn() => v::space('c')->assert('cd'), - fn(string $message) => expect($message)->toBe('"cd" must contain only space characters and "c"') + fn(string $message) => expect($message)->toBe('"cd" must contain only space characters and "c"'), )); test('Scenario #3', catchMessage( fn() => v::not(v::space())->assert("\t"), - fn(string $message) => expect($message)->toBe('"\\t" must not contain space characters') + fn(string $message) => expect($message)->toBe('"\\t" must not contain space characters'), )); test('Scenario #4', catchMessage( fn() => v::not(v::space('def'))->assert("\r"), - fn(string $message) => expect($message)->toBe('"\\r" must not contain space characters or "def"') + fn(string $message) => expect($message)->toBe('"\\r" must not contain space characters or "def"'), )); test('Scenario #5', catchFullMessage( fn() => v::space()->assert('ef'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "ef" must contain only space characters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "ef" must contain only space characters'), )); test('Scenario #6', catchFullMessage( fn() => v::space('e')->assert('gh'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "gh" must contain only space characters and "e"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "gh" must contain only space characters and "e"'), )); test('Scenario #7', catchFullMessage( fn() => v::not(v::space())->assert("\n"), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "\\n" must not contain space characters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "\\n" must not contain space characters'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::space('yk'))->assert(' k'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- " k" must not contain space characters or "yk"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- " k" must not contain space characters or "yk"'), )); diff --git a/tests/feature/Rules/StartsWithTest.php b/tests/feature/Rules/StartsWithTest.php index c418ee24..cec4cb8e 100644 --- a/tests/feature/Rules/StartsWithTest.php +++ b/tests/feature/Rules/StartsWithTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::startsWith('b')->assert(['a', 'b']), - fn(string $message) => expect($message)->toBe('`["a", "b"]` must start with "b"') + fn(string $message) => expect($message)->toBe('`["a", "b"]` must start with "b"'), )); test('Scenario #2', catchMessage( fn() => v::not(v::startsWith(1.1))->assert([1.1, 2.2]), - fn(string $message) => expect($message)->toBe('`[1.1, 2.2]` must not start with 1.1') + fn(string $message) => expect($message)->toBe('`[1.1, 2.2]` must not start with 1.1'), )); test('Scenario #3', catchFullMessage( fn() => v::startsWith('3.3', true)->assert([3.3, 4.4]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[3.3, 4.4]` must start with "3.3"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[3.3, 4.4]` must start with "3.3"'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::startsWith('c'))->assert(['c', 'd']), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `["c", "d"]` must not start with "c"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `["c", "d"]` must not start with "c"'), )); diff --git a/tests/feature/Rules/StringTypeTest.php b/tests/feature/Rules/StringTypeTest.php index 1f0c9098..3191ac96 100644 --- a/tests/feature/Rules/StringTypeTest.php +++ b/tests/feature/Rules/StringTypeTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::stringType()->assert(42), - fn(string $message) => expect($message)->toBe('42 must be a string') + fn(string $message) => expect($message)->toBe('42 must be a string'), )); test('Scenario #2', catchMessage( fn() => v::not(v::stringType())->assert('foo'), - fn(string $message) => expect($message)->toBe('"foo" must not be a string') + fn(string $message) => expect($message)->toBe('"foo" must not be a string'), )); test('Scenario #3', catchFullMessage( fn() => v::stringType()->assert(true), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must be a string') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `true` must be a string'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::stringType())->assert('bar'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "bar" must not be a string') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "bar" must not be a string'), )); diff --git a/tests/feature/Rules/StringValTest.php b/tests/feature/Rules/StringValTest.php index 41a067a7..bed20228 100644 --- a/tests/feature/Rules/StringValTest.php +++ b/tests/feature/Rules/StringValTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::stringVal()->assert([]), - fn(string $message) => expect($message)->toBe('`[]` must be a string value') + fn(string $message) => expect($message)->toBe('`[]` must be a string value'), )); test('Scenario #2', catchMessage( fn() => v::not(v::stringVal())->assert(true), - fn(string $message) => expect($message)->toBe('`true` must not be a string value') + fn(string $message) => expect($message)->toBe('`true` must not be a string value'), )); test('Scenario #3', catchFullMessage( fn() => v::stringVal()->assert(new stdClass()), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be a string value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `stdClass {}` must be a string value'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::stringVal())->assert(42), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 42 must not be a string value') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 42 must not be a string value'), )); diff --git a/tests/feature/Rules/SubsetTest.php b/tests/feature/Rules/SubsetTest.php index bcc68deb..5b04f979 100644 --- a/tests/feature/Rules/SubsetTest.php +++ b/tests/feature/Rules/SubsetTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::subset([1, 2])->assert([1, 2, 3]), - fn(string $message) => expect($message)->toBe('`[1, 2, 3]` must be subset of `[1, 2]`') + fn(string $message) => expect($message)->toBe('`[1, 2, 3]` must be subset of `[1, 2]`'), )); test('Scenario #2', catchMessage( fn() => v::not(v::subset([1, 2, 3]))->assert([1, 2]), - fn(string $message) => expect($message)->toBe('`[1, 2]` must not be subset of `[1, 2, 3]`') + fn(string $message) => expect($message)->toBe('`[1, 2]` must not be subset of `[1, 2, 3]`'), )); test('Scenario #3', catchFullMessage( fn() => v::subset(['A', 'B'])->assert(['B', 'C']), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `["B", "C"]` must be subset of `["A", "B"]`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `["B", "C"]` must be subset of `["A", "B"]`'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::subset(['A']))->assert(['A']), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `["A"]` must not be subset of `["A"]`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `["A"]` must not be subset of `["A"]`'), )); diff --git a/tests/feature/Rules/SymbolicLinkTest.php b/tests/feature/Rules/SymbolicLinkTest.php index 09b8ba92..77f1ca6b 100644 --- a/tests/feature/Rules/SymbolicLinkTest.php +++ b/tests/feature/Rules/SymbolicLinkTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::symbolicLink()->assert('tests/fixtures/fake-filename'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/fake-filename" must be a symbolic link') + fn(string $message) => expect($message)->toBe('"tests/fixtures/fake-filename" must be a symbolic link'), )); test('Scenario #2', catchMessage( fn() => v::not(v::symbolicLink())->assert('tests/fixtures/symbolic-link'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/symbolic-link" must not be a symbolic link') + fn(string $message) => expect($message)->toBe('"tests/fixtures/symbolic-link" must not be a symbolic link'), )); test('Scenario #3', catchFullMessage( fn() => v::symbolicLink()->assert('tests/fixtures/fake-filename'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/fake-filename" must be a symbolic link') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/fake-filename" must be a symbolic link'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::symbolicLink())->assert('tests/fixtures/symbolic-link'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/symbolic-link" must not be a symbolic link') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/symbolic-link" must not be a symbolic link'), )); diff --git a/tests/feature/Rules/TemplatedTest.php b/tests/feature/Rules/TemplatedTest.php index e94f9c42..f021c760 100644 --- a/tests/feature/Rules/TemplatedTest.php +++ b/tests/feature/Rules/TemplatedTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Template in "Templated"') ->and($fullMessage)->toBe('- Template in "Templated"') - ->and($messages)->toBe(['stringType' => 'Template in "Templated"']) + ->and($messages)->toBe(['stringType' => 'Template in "Templated"']), )); test('With parameters', catchAll( @@ -20,7 +20,7 @@ test('With parameters', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Template in "Templated"') ->and($fullMessage)->toBe('- Template in "Templated"') - ->and($messages)->toBe(['stringType' => 'Template in "Templated"']) + ->and($messages)->toBe(['stringType' => 'Template in "Templated"']), )); test('Inverted', catchAll( @@ -28,7 +28,7 @@ test('Inverted', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Template in "Templated"') ->and($fullMessage)->toBe('- Template in "Templated"') - ->and($messages)->toBe(['notIntType' => 'Template in "Templated"']) + ->and($messages)->toBe(['notIntType' => 'Template in "Templated"']), )); test('Template in Validator', catchAll( @@ -38,7 +38,7 @@ test('Template in Validator', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Template in "Templated"') ->and($fullMessage)->toBe('- Template in "Templated"') - ->and($messages)->toBe(['stringType' => 'Template in "Templated"']) + ->and($messages)->toBe(['stringType' => 'Template in "Templated"']), )); test('Template passed to Validator::assert()', catchAll( @@ -46,7 +46,7 @@ test('Template passed to Validator::assert()', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Template in "Templated"') ->and($fullMessage)->toBe('- Template in "Templated"') - ->and($messages)->toBe(['stringType' => 'Template in "Templated"']) + ->and($messages)->toBe(['stringType' => 'Template in "Templated"']), )); test('With bound', catchAll( @@ -54,5 +54,5 @@ test('With bound', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Template in "Templated"') ->and($fullMessage)->toBe('- Template in "Templated"') - ->and($messages)->toBe(['attributes' => 'Template in "Templated"']) + ->and($messages)->toBe(['attributes' => 'Template in "Templated"']), )); diff --git a/tests/feature/Rules/TimeTest.php b/tests/feature/Rules/TimeTest.php index 86e1144d..c305be79 100644 --- a/tests/feature/Rules/TimeTest.php +++ b/tests/feature/Rules/TimeTest.php @@ -11,20 +11,20 @@ date_default_timezone_set('UTC'); test('Scenario #1', catchMessage( fn() => v::time()->assert('2018-01-30'), - fn(string $message) => expect($message)->toBe('"2018-01-30" must be a valid time in the format "23:59:59"') + fn(string $message) => expect($message)->toBe('"2018-01-30" must be a valid time in the format "23:59:59"'), )); test('Scenario #2', catchMessage( fn() => v::not(v::time())->assert('09:25:46'), - fn(string $message) => expect($message)->toBe('"09:25:46" must not be a valid time in the format "23:59:59"') + fn(string $message) => expect($message)->toBe('"09:25:46" must not be a valid time in the format "23:59:59"'), )); test('Scenario #3', catchFullMessage( fn() => v::time()->assert('2018-01-30'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "2018-01-30" must be a valid time in the format "23:59:59"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "2018-01-30" must be a valid time in the format "23:59:59"'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::time('g:i A'))->assert('8:13 AM'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "8:13 AM" must not be a valid time in the format "11:59 PM"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "8:13 AM" must not be a valid time in the format "11:59 PM"'), )); diff --git a/tests/feature/Rules/TldTest.php b/tests/feature/Rules/TldTest.php index 11eddc5d..5a6041f2 100644 --- a/tests/feature/Rules/TldTest.php +++ b/tests/feature/Rules/TldTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::tld()->assert('42'), - fn(string $message) => expect($message)->toBe('"42" must be a valid top-level domain name') + fn(string $message) => expect($message)->toBe('"42" must be a valid top-level domain name'), )); test('Scenario #2', catchMessage( fn() => v::not(v::tld())->assert('com'), - fn(string $message) => expect($message)->toBe('"com" must not be a valid top-level domain name') + fn(string $message) => expect($message)->toBe('"com" must not be a valid top-level domain name'), )); test('Scenario #3', catchFullMessage( fn() => v::tld()->assert('1984'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1984" must be a valid top-level domain name') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1984" must be a valid top-level domain name'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::tld())->assert('com'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "com" must not be a valid top-level domain name') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "com" must not be a valid top-level domain name'), )); diff --git a/tests/feature/Rules/TrueValTest.php b/tests/feature/Rules/TrueValTest.php index b1795374..e1e2feaa 100644 --- a/tests/feature/Rules/TrueValTest.php +++ b/tests/feature/Rules/TrueValTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::trueVal()->assert(false), - fn(string $message) => expect($message)->toBe('`false` must evaluate to `true`') + fn(string $message) => expect($message)->toBe('`false` must evaluate to `true`'), )); test('Scenario #2', catchMessage( fn() => v::not(v::trueVal())->assert(1), - fn(string $message) => expect($message)->toBe('1 must not evaluate to `true`') + fn(string $message) => expect($message)->toBe('1 must not evaluate to `true`'), )); test('Scenario #3', catchFullMessage( fn() => v::trueVal()->assert(0), - fn(string $fullMessage) => expect($fullMessage)->toBe('- 0 must evaluate to `true`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- 0 must evaluate to `true`'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::trueVal())->assert('true'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "true" must not evaluate to `true`') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "true" must not evaluate to `true`'), )); diff --git a/tests/feature/Rules/UndefOrTest.php b/tests/feature/Rules/UndefOrTest.php index 62ae3932..b61836d6 100644 --- a/tests/feature/Rules/UndefOrTest.php +++ b/tests/feature/Rules/UndefOrTest.php @@ -12,7 +12,7 @@ test('Default', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('1234 must contain only letters (a-z) or must be undefined') ->and($fullMessage)->toBe('- 1234 must contain only letters (a-z) or must be undefined') - ->and($messages)->toBe(['undefOrAlpha' => '1234 must contain only letters (a-z) or must be undefined']) + ->and($messages)->toBe(['undefOrAlpha' => '1234 must contain only letters (a-z) or must be undefined']), )); test('Inverted wrapper', catchAll( @@ -20,7 +20,7 @@ test('Inverted wrapper', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"alpha" must not contain letters (a-z) and must not be undefined') ->and($fullMessage)->toBe('- "alpha" must not contain letters (a-z) and must not be undefined') - ->and($messages)->toBe(['notUndefOrAlpha' => '"alpha" must not contain letters (a-z) and must not be undefined']) + ->and($messages)->toBe(['notUndefOrAlpha' => '"alpha" must not contain letters (a-z) and must not be undefined']), )); test('Inverted wrapped', catchAll( @@ -28,7 +28,7 @@ test('Inverted wrapped', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"alpha" must not contain letters (a-z) or must be undefined') ->and($fullMessage)->toBe('- "alpha" must not contain letters (a-z) or must be undefined') - ->and($messages)->toBe(['undefOrNotAlpha' => '"alpha" must not contain letters (a-z) or must be undefined']) + ->and($messages)->toBe(['undefOrNotAlpha' => '"alpha" must not contain letters (a-z) or must be undefined']), )); test('Inverted undefined', catchAll( @@ -36,7 +36,7 @@ test('Inverted undefined', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`null` must not contain letters (a-z) and must not be undefined') ->and($fullMessage)->toBe('- `null` must not contain letters (a-z) and must not be undefined') - ->and($messages)->toBe(['notUndefOrAlpha' => '`null` must not contain letters (a-z) and must not be undefined']) + ->and($messages)->toBe(['notUndefOrAlpha' => '`null` must not contain letters (a-z) and must not be undefined']), )); test('Inverted undefined, wrapped name', catchAll( @@ -44,7 +44,7 @@ test('Inverted undefined, wrapped name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapped must not contain letters (a-z) and must not be undefined') ->and($fullMessage)->toBe('- Wrapped must not contain letters (a-z) and must not be undefined') - ->and($messages)->toBe(['notUndefOrAlpha' => 'Wrapped must not contain letters (a-z) and must not be undefined']) + ->and($messages)->toBe(['notUndefOrAlpha' => 'Wrapped must not contain letters (a-z) and must not be undefined']), )); test('Inverted undefined, wrapper name', catchAll( @@ -52,7 +52,7 @@ test('Inverted undefined, wrapper name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Wrapper must not contain letters (a-z) and must not be undefined') ->and($fullMessage)->toBe('- Wrapper must not contain letters (a-z) and must not be undefined') - ->and($messages)->toBe(['notUndefOrAlpha' => 'Wrapper must not contain letters (a-z) and must not be undefined']) + ->and($messages)->toBe(['notUndefOrAlpha' => 'Wrapper must not contain letters (a-z) and must not be undefined']), )); test('Inverted undefined, not name', catchAll( @@ -60,7 +60,7 @@ test('Inverted undefined, not name', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not must not contain letters (a-z) and must not be undefined') ->and($fullMessage)->toBe('- Not must not contain letters (a-z) and must not be undefined') - ->and($messages)->toBe(['notUndefOrAlpha' => 'Not must not contain letters (a-z) and must not be undefined']) + ->and($messages)->toBe(['notUndefOrAlpha' => 'Not must not contain letters (a-z) and must not be undefined']), )); test('With template', catchAll( @@ -68,7 +68,7 @@ test('With template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Underneath the undulating umbrella') ->and($fullMessage)->toBe('- Underneath the undulating umbrella') - ->and($messages)->toBe(['undefOrAlpha' => 'Underneath the undulating umbrella']) + ->and($messages)->toBe(['undefOrAlpha' => 'Underneath the undulating umbrella']), )); test('With array template', catchAll( @@ -76,7 +76,7 @@ test('With array template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Undefined number of unique unicorns') ->and($fullMessage)->toBe('- Undefined number of unique unicorns') - ->and($messages)->toBe(['undefOrAlpha' => 'Undefined number of unique unicorns']) + ->and($messages)->toBe(['undefOrAlpha' => 'Undefined number of unique unicorns']), )); test('Inverted undefined with template', catchAll( @@ -84,7 +84,7 @@ test('Inverted undefined with template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Should not be undefined or alpha') ->and($fullMessage)->toBe('- Should not be undefined or alpha') - ->and($messages)->toBe(['notUndefOrAlpha' => 'Should not be undefined or alpha']) + ->and($messages)->toBe(['notUndefOrAlpha' => 'Should not be undefined or alpha']), )); test('Without adjacent result', catchAll( @@ -100,7 +100,7 @@ test('Without adjacent result', catchAll( '__root__' => '1234 must pass all the rules', 'undefOrAlpha' => '1234 must contain only letters (a-z) or must be undefined', 'undefOrStringType' => '1234 must be a string or must be undefined', - ]) + ]), )); test('Without adjacent result with templates', catchAll( @@ -119,5 +119,5 @@ test('Without adjacent result with templates', catchAll( '__root__' => '1234 must pass all the rules', 'undefOrAlpha' => 'Should be nul or alpha', 'undefOrStringType' => 'Should be nul or string type', - ]) + ]), )); diff --git a/tests/feature/Rules/UniqueTest.php b/tests/feature/Rules/UniqueTest.php index 1e784ae8..98c24b7c 100644 --- a/tests/feature/Rules/UniqueTest.php +++ b/tests/feature/Rules/UniqueTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::unique()->assert([1, 2, 2, 3]), - fn(string $message) => expect($message)->toBe('`[1, 2, 2, 3]` must not contain duplicates') + fn(string $message) => expect($message)->toBe('`[1, 2, 2, 3]` must not contain duplicates'), )); test('Scenario #2', catchMessage( fn() => v::not(v::unique())->assert([1, 2, 3, 4]), - fn(string $message) => expect($message)->toBe('`[1, 2, 3, 4]` must contain duplicates') + fn(string $message) => expect($message)->toBe('`[1, 2, 3, 4]` must contain duplicates'), )); test('Scenario #3', catchFullMessage( fn() => v::unique()->assert('test'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "test" must not contain duplicates') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "test" must not contain duplicates'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::unique())->assert(['a', 'b', 'c']), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `["a", "b", "c"]` must contain duplicates') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `["a", "b", "c"]` must contain duplicates'), )); diff --git a/tests/feature/Rules/UploadedTest.php b/tests/feature/Rules/UploadedTest.php index 06d87feb..0ba932be 100644 --- a/tests/feature/Rules/UploadedTest.php +++ b/tests/feature/Rules/UploadedTest.php @@ -12,7 +12,7 @@ test('Scenario #1', catchMessage( set_mock_is_uploaded_file_return(false); v::uploaded()->assert('filename'); }, - fn(string $message) => expect($message)->toBe('"filename" must be an uploaded file') + fn(string $message) => expect($message)->toBe('"filename" must be an uploaded file'), )); test('Scenario #2', catchMessage( @@ -20,7 +20,7 @@ test('Scenario #2', catchMessage( set_mock_is_uploaded_file_return(true); v::not(v::uploaded())->assert('filename'); }, - fn(string $message) => expect($message)->toBe('"filename" must not be an uploaded file') + fn(string $message) => expect($message)->toBe('"filename" must not be an uploaded file'), )); test('Scenario #3', catchFullMessage( @@ -28,7 +28,7 @@ test('Scenario #3', catchFullMessage( set_mock_is_uploaded_file_return(false); v::uploaded()->assert('filename'); }, - fn(string $fullMessage) => expect($fullMessage)->toBe('- "filename" must be an uploaded file') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "filename" must be an uploaded file'), )); test('Scenario #4', catchFullMessage( @@ -36,5 +36,5 @@ test('Scenario #4', catchFullMessage( set_mock_is_uploaded_file_return(true); v::not(v::uploaded())->assert('filename'); }, - fn(string $fullMessage) => expect($fullMessage)->toBe('- "filename" must not be an uploaded file') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "filename" must not be an uploaded file'), )); diff --git a/tests/feature/Rules/UppercaseTest.php b/tests/feature/Rules/UppercaseTest.php index 97081f6d..d40389eb 100644 --- a/tests/feature/Rules/UppercaseTest.php +++ b/tests/feature/Rules/UppercaseTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::uppercase()->assert('lowercase'), - fn(string $message) => expect($message)->toBe('"lowercase" must contain only uppercase letters') + fn(string $message) => expect($message)->toBe('"lowercase" must contain only uppercase letters'), )); test('Scenario #2', catchFullMessage( fn() => v::uppercase()->assert('lowercase'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "lowercase" must contain only uppercase letters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "lowercase" must contain only uppercase letters'), )); test('Scenario #3', catchMessage( fn() => v::not(v::uppercase())->assert('UPPERCASE'), - fn(string $message) => expect($message)->toBe('"UPPERCASE" must not contain only uppercase letters') + fn(string $message) => expect($message)->toBe('"UPPERCASE" must not contain only uppercase letters'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::uppercase())->assert('UPPERCASE'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "UPPERCASE" must not contain only uppercase letters') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "UPPERCASE" must not contain only uppercase letters'), )); diff --git a/tests/feature/Rules/UrlTest.php b/tests/feature/Rules/UrlTest.php index bdf11a54..85006362 100644 --- a/tests/feature/Rules/UrlTest.php +++ b/tests/feature/Rules/UrlTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::url()->assert('example.com'), - fn(string $message) => expect($message)->toBe('"example.com" must be a URL') + fn(string $message) => expect($message)->toBe('"example.com" must be a URL'), )); test('Scenario #2', catchMessage( fn() => v::not(v::url())->assert('http://example.com'), - fn(string $message) => expect($message)->toBe('"http://example.com" must not be a URL') + fn(string $message) => expect($message)->toBe('"http://example.com" must not be a URL'), )); test('Scenario #3', catchFullMessage( fn() => v::url()->assert('example.com'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "example.com" must be a URL') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "example.com" must be a URL'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::url())->assert('http://example.com'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "http://example.com" must not be a URL') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "http://example.com" must not be a URL'), )); diff --git a/tests/feature/Rules/UuidTest.php b/tests/feature/Rules/UuidTest.php index 2c83c5e6..e8661ae9 100644 --- a/tests/feature/Rules/UuidTest.php +++ b/tests/feature/Rules/UuidTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::uuid()->assert('g71a18f4-3a13-11e7-a919-92ebcb67fe33'), - fn(string $message) => expect($message)->toBe('"g71a18f4-3a13-11e7-a919-92ebcb67fe33" must be a valid UUID') + fn(string $message) => expect($message)->toBe('"g71a18f4-3a13-11e7-a919-92ebcb67fe33" must be a valid UUID'), )); test('Scenario #2', catchMessage( fn() => v::uuid(1)->assert('e0b5ffb9-9caf-2a34-9673-8fc91db78be6'), - fn(string $message) => expect($message)->toBe('"e0b5ffb9-9caf-2a34-9673-8fc91db78be6" must be a valid UUID version 1') + fn(string $message) => expect($message)->toBe('"e0b5ffb9-9caf-2a34-9673-8fc91db78be6" must be a valid UUID version 1'), )); test('Scenario #3', catchMessage( fn() => v::not(v::uuid())->assert('fb3a7909-8034-59f5-8f38-21adbc168db7'), - fn(string $message) => expect($message)->toBe('"fb3a7909-8034-59f5-8f38-21adbc168db7" must not be a valid UUID') + fn(string $message) => expect($message)->toBe('"fb3a7909-8034-59f5-8f38-21adbc168db7" must not be a valid UUID'), )); test('Scenario #4', catchMessage( fn() => v::not(v::uuid(3))->assert('11a38b9a-b3da-360f-9353-a5a725514269'), - fn(string $message) => expect($message)->toBe('"11a38b9a-b3da-360f-9353-a5a725514269" must not be a valid UUID version 3') + fn(string $message) => expect($message)->toBe('"11a38b9a-b3da-360f-9353-a5a725514269" must not be a valid UUID version 3'), )); test('Scenario #5', catchFullMessage( fn() => v::uuid()->assert('g71a18f4-3a13-11e7-a919-92ebcb67fe33'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "g71a18f4-3a13-11e7-a919-92ebcb67fe33" must be a valid UUID') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "g71a18f4-3a13-11e7-a919-92ebcb67fe33" must be a valid UUID'), )); test('Scenario #6', catchFullMessage( fn() => v::uuid(4)->assert('a71a18f4-3a13-11e7-a919-92ebcb67fe33'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "a71a18f4-3a13-11e7-a919-92ebcb67fe33" must be a valid UUID version 4') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "a71a18f4-3a13-11e7-a919-92ebcb67fe33" must be a valid UUID version 4'), )); test('Scenario #7', catchFullMessage( fn() => v::not(v::uuid())->assert('e0b5ffb9-9caf-4a34-9673-8fc91db78be6'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "e0b5ffb9-9caf-4a34-9673-8fc91db78be6" must not be a valid UUID') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "e0b5ffb9-9caf-4a34-9673-8fc91db78be6" must not be a valid UUID'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::uuid(5))->assert('c4a760a8-dbcf-5254-a0d9-6a4474bd1b62'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "c4a760a8-dbcf-5254-a0d9-6a4474bd1b62" must not be a valid UUID version 5') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "c4a760a8-dbcf-5254-a0d9-6a4474bd1b62" must not be a valid UUID version 5'), )); diff --git a/tests/feature/Rules/VersionTest.php b/tests/feature/Rules/VersionTest.php index f9359374..e758132f 100644 --- a/tests/feature/Rules/VersionTest.php +++ b/tests/feature/Rules/VersionTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::version()->assert('1.3.7--'), - fn(string $message) => expect($message)->toBe('"1.3.7--" must be a version') + fn(string $message) => expect($message)->toBe('"1.3.7--" must be a version'), )); test('Scenario #2', catchMessage( fn() => v::not(v::version())->assert('1.0.0-alpha'), - fn(string $message) => expect($message)->toBe('"1.0.0-alpha" must not be a version') + fn(string $message) => expect($message)->toBe('"1.0.0-alpha" must not be a version'), )); test('Scenario #3', catchFullMessage( fn() => v::version()->assert('1.2.3.4-beta'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1.2.3.4-beta" must be a version') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1.2.3.4-beta" must be a version'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::version())->assert('1.3.7-rc.1'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "1.3.7-rc.1" must not be a version') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "1.3.7-rc.1" must not be a version'), )); diff --git a/tests/feature/Rules/VideoUrlTest.php b/tests/feature/Rules/VideoUrlTest.php index 2ebb90c6..bdf39ad3 100644 --- a/tests/feature/Rules/VideoUrlTest.php +++ b/tests/feature/Rules/VideoUrlTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::videoUrl()->assert('example.com'), - fn(string $message) => expect($message)->toBe('"example.com" must be a valid video URL') + fn(string $message) => expect($message)->toBe('"example.com" must be a valid video URL'), )); test('Scenario #2', catchMessage( fn() => v::videoUrl('YouTube')->assert('example.com'), - fn(string $message) => expect($message)->toBe('"example.com" must be a valid YouTube video URL') + fn(string $message) => expect($message)->toBe('"example.com" must be a valid YouTube video URL'), )); test('Scenario #3', catchMessage( fn() => v::not(v::videoUrl())->assert('https://player.vimeo.com/video/7178746722'), - fn(string $message) => expect($message)->toBe('"https://player.vimeo.com/video/7178746722" must not be a valid video URL') + fn(string $message) => expect($message)->toBe('"https://player.vimeo.com/video/7178746722" must not be a valid video URL'), )); test('Scenario #4', catchMessage( fn() => v::not(v::videoUrl('YouTube'))->assert('https://www.youtube.com/embed/netHLn9TScY'), - fn(string $message) => expect($message)->toBe('"https://www.youtube.com/embed/netHLn9TScY" must not be a valid YouTube video URL') + fn(string $message) => expect($message)->toBe('"https://www.youtube.com/embed/netHLn9TScY" must not be a valid YouTube video URL'), )); test('Scenario #5', catchFullMessage( fn() => v::videoUrl()->assert('example.com'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "example.com" must be a valid video URL') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "example.com" must be a valid video URL'), )); test('Scenario #6', catchFullMessage( fn() => v::videoUrl('Vimeo')->assert('example.com'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "example.com" must be a valid Vimeo video URL') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "example.com" must be a valid Vimeo video URL'), )); test('Scenario #7', catchFullMessage( fn() => v::not(v::videoUrl())->assert('https://youtu.be/netHLn9TScY'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "https://youtu.be/netHLn9TScY" must not be a valid video URL') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "https://youtu.be/netHLn9TScY" must not be a valid video URL'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::videoUrl('Vimeo'))->assert('https://vimeo.com/71787467'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "https://vimeo.com/71787467" must not be a valid Vimeo video URL') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "https://vimeo.com/71787467" must not be a valid Vimeo video URL'), )); diff --git a/tests/feature/Rules/VowelTest.php b/tests/feature/Rules/VowelTest.php index d987816f..267144fc 100644 --- a/tests/feature/Rules/VowelTest.php +++ b/tests/feature/Rules/VowelTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::vowel()->assert('b'), - fn(string $message) => expect($message)->toBe('"b" must consist of vowels only') + fn(string $message) => expect($message)->toBe('"b" must consist of vowels only'), )); test('Scenario #2', catchMessage( fn() => v::vowel('c')->assert('d'), - fn(string $message) => expect($message)->toBe('"d" must consist of vowels and "c"') + fn(string $message) => expect($message)->toBe('"d" must consist of vowels and "c"'), )); test('Scenario #3', catchMessage( fn() => v::not(v::vowel())->assert('a'), - fn(string $message) => expect($message)->toBe('"a" must not consist of vowels only') + fn(string $message) => expect($message)->toBe('"a" must not consist of vowels only'), )); test('Scenario #4', catchMessage( fn() => v::not(v::vowel('f'))->assert('e'), - fn(string $message) => expect($message)->toBe('"e" must not consist of vowels or "f"') + fn(string $message) => expect($message)->toBe('"e" must not consist of vowels or "f"'), )); test('Scenario #5', catchFullMessage( fn() => v::vowel()->assert('g'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "g" must consist of vowels only') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "g" must consist of vowels only'), )); test('Scenario #6', catchFullMessage( fn() => v::vowel('h')->assert('j'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "j" must consist of vowels and "h"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "j" must consist of vowels and "h"'), )); test('Scenario #7', catchFullMessage( fn() => v::not(v::vowel())->assert('i'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "i" must not consist of vowels only') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "i" must not consist of vowels only'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::vowel('k'))->assert('o'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "o" must not consist of vowels or "k"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "o" must not consist of vowels or "k"'), )); diff --git a/tests/feature/Rules/WhenTest.php b/tests/feature/Rules/WhenTest.php index 9a3a5926..462af8e1 100644 --- a/tests/feature/Rules/WhenTest.php +++ b/tests/feature/Rules/WhenTest.php @@ -12,7 +12,7 @@ test('When valid use "then"', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('-1 must be a positive number') ->and($fullMessage)->toBe('- -1 must be a positive number') - ->and($messages)->toBe(['positive' => '-1 must be a positive number']) + ->and($messages)->toBe(['positive' => '-1 must be a positive number']), )); test('When invalid use "else"', catchAll( @@ -20,7 +20,7 @@ test('When invalid use "else"', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"" must not be empty') ->and($fullMessage)->toBe('- "" must not be empty') - ->and($messages)->toBe(['notEmpty' => '"" must not be empty']) + ->and($messages)->toBe(['notEmpty' => '"" must not be empty']), )); test('When valid use "then" using single template', catchAll( @@ -28,7 +28,7 @@ test('When valid use "then" using single template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('That did not go as planned') ->and($fullMessage)->toBe('- That did not go as planned') - ->and($messages)->toBe(['positive' => 'That did not go as planned']) + ->and($messages)->toBe(['positive' => 'That did not go as planned']), )); test('When invalid use "else" using single template', catchAll( @@ -36,7 +36,7 @@ test('When invalid use "else" using single template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('That could have been better') ->and($fullMessage)->toBe('- That could have been better') - ->and($messages)->toBe(['notEmpty' => 'That could have been better']) + ->and($messages)->toBe(['notEmpty' => 'That could have been better']), )); test('When valid use "then" using array template', catchAll( @@ -47,7 +47,7 @@ test('When valid use "then" using array template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not positive') ->and($fullMessage)->toBe('- Not positive') - ->and($messages)->toBe(['positive' => 'Not positive']) + ->and($messages)->toBe(['positive' => 'Not positive']), )); test('When invalid use "else" using array template', catchAll( @@ -58,5 +58,5 @@ test('When invalid use "else" using array template', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('Not empty') ->and($fullMessage)->toBe('- Not empty') - ->and($messages)->toBe(['notEmpty' => 'Not empty']) + ->and($messages)->toBe(['notEmpty' => 'Not empty']), )); diff --git a/tests/feature/Rules/WritableTest.php b/tests/feature/Rules/WritableTest.php index d1ef5df4..ce28c0e2 100644 --- a/tests/feature/Rules/WritableTest.php +++ b/tests/feature/Rules/WritableTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::writable()->assert('/path/of/a/valid/writable/file.txt'), - fn(string $message) => expect($message)->toBe('"/path/of/a/valid/writable/file.txt" must be writable') + fn(string $message) => expect($message)->toBe('"/path/of/a/valid/writable/file.txt" must be writable'), )); test('Scenario #2', catchMessage( fn() => v::not(v::writable())->assert('tests/fixtures/valid-image.png'), - fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.png" must not be writable') + fn(string $message) => expect($message)->toBe('"tests/fixtures/valid-image.png" must not be writable'), )); test('Scenario #3', catchFullMessage( fn() => v::writable()->assert([]), - fn(string $fullMessage) => expect($fullMessage)->toBe('- `[]` must be writable') + fn(string $fullMessage) => expect($fullMessage)->toBe('- `[]` must be writable'), )); test('Scenario #4', catchFullMessage( fn() => v::not(v::writable())->assert('tests/fixtures/invalid-image.png'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/invalid-image.png" must not be writable') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "tests/fixtures/invalid-image.png" must not be writable'), )); diff --git a/tests/feature/Rules/XdigitTest.php b/tests/feature/Rules/XdigitTest.php index 3c2c7326..e2ad9d8d 100644 --- a/tests/feature/Rules/XdigitTest.php +++ b/tests/feature/Rules/XdigitTest.php @@ -9,40 +9,40 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::xdigit()->assert('aaa%a'), - fn(string $message) => expect($message)->toBe('"aaa%a" must only contain hexadecimal digits') + fn(string $message) => expect($message)->toBe('"aaa%a" must only contain hexadecimal digits'), )); test('Scenario #2', catchMessage( fn() => v::xdigit(' ')->assert('bbb%b'), - fn(string $message) => expect($message)->toBe('"bbb%b" must contain hexadecimal digits and " "') + fn(string $message) => expect($message)->toBe('"bbb%b" must contain hexadecimal digits and " "'), )); test('Scenario #3', catchMessage( fn() => v::not(v::xdigit())->assert('ccccc'), - fn(string $message) => expect($message)->toBe('"ccccc" must not only contain hexadecimal digits') + fn(string $message) => expect($message)->toBe('"ccccc" must not only contain hexadecimal digits'), )); test('Scenario #4', catchMessage( fn() => v::not(v::xdigit('% '))->assert('ddd%d'), - fn(string $message) => expect($message)->toBe('"ddd%d" must not contain hexadecimal digits or "% "') + fn(string $message) => expect($message)->toBe('"ddd%d" must not contain hexadecimal digits or "% "'), )); test('Scenario #5', catchFullMessage( fn() => v::xdigit()->assert('eee^e'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "eee^e" must only contain hexadecimal digits') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "eee^e" must only contain hexadecimal digits'), )); test('Scenario #6', catchFullMessage( fn() => v::not(v::xdigit())->assert('fffff'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "fffff" must not only contain hexadecimal digits') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "fffff" must not only contain hexadecimal digits'), )); test('Scenario #7', catchFullMessage( fn() => v::xdigit('* &%')->assert('000^0'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "000^0" must contain hexadecimal digits and "* &%"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "000^0" must contain hexadecimal digits and "* &%"'), )); test('Scenario #8', catchFullMessage( fn() => v::not(v::xdigit('^'))->assert('111^1'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "111^1" must not contain hexadecimal digits or "^"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "111^1" must not contain hexadecimal digits or "^"'), )); diff --git a/tests/feature/Rules/YesTest.php b/tests/feature/Rules/YesTest.php index c56a1c77..4baa5f77 100644 --- a/tests/feature/Rules/YesTest.php +++ b/tests/feature/Rules/YesTest.php @@ -9,20 +9,20 @@ declare(strict_types=1); test('Scenario #1', catchMessage( fn() => v::not(v::yes())->assert('Yes'), - fn(string $message) => expect($message)->toBe('"Yes" must not be similar to "Yes"') + fn(string $message) => expect($message)->toBe('"Yes" must not be similar to "Yes"'), )); test('Scenario #2', catchMessage( fn() => v::yes()->assert('si'), - fn(string $message) => expect($message)->toBe('"si" must be similar to "Yes"') + fn(string $message) => expect($message)->toBe('"si" must be similar to "Yes"'), )); test('Scenario #3', catchFullMessage( fn() => v::not(v::yes())->assert('Yes'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "Yes" must not be similar to "Yes"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "Yes" must not be similar to "Yes"'), )); test('Scenario #4', catchFullMessage( fn() => v::yes()->assert('si'), - fn(string $fullMessage) => expect($fullMessage)->toBe('- "si" must be similar to "Yes"') + fn(string $fullMessage) => expect($fullMessage)->toBe('- "si" must be similar to "Yes"'), )); diff --git a/tests/feature/SetTemplateWithSingleValidatorShouldUseTemplateAsMainMessageTest.php b/tests/feature/SetTemplateWithSingleValidatorShouldUseTemplateAsMainMessageTest.php index e6a10016..487005ad 100644 --- a/tests/feature/SetTemplateWithSingleValidatorShouldUseTemplateAsMainMessageTest.php +++ b/tests/feature/SetTemplateWithSingleValidatorShouldUseTemplateAsMainMessageTest.php @@ -11,5 +11,5 @@ use Respect\Validation\Validator; test('Scenario', catchMessage( fn() => Validator::callback('is_int')->setTemplate('{{name}} is not tasty')->assert('something'), - fn(string $message) => expect($message)->toBe('"something" is not tasty') + fn(string $message) => expect($message)->toBe('"something" is not tasty'), )); diff --git a/tests/feature/ShouldNotOverwriteDefinedNamesTest.php b/tests/feature/ShouldNotOverwriteDefinedNamesTest.php index e147a840..30427318 100644 --- a/tests/feature/ShouldNotOverwriteDefinedNamesTest.php +++ b/tests/feature/ShouldNotOverwriteDefinedNamesTest.php @@ -11,15 +11,15 @@ $input = ['email' => 'not an email']; test('Scenario #1', catchMessage( fn() => v::key('email', v::email()->setName('Email'))->setName('Foo')->assert($input), - fn(string $message) => expect($message)->toBe('Email must be a valid email address') + fn(string $message) => expect($message)->toBe('Email must be a valid email address'), )); test('Scenario #2', catchMessage( fn() => v::key('email', v::email())->setName('Email')->assert($input), - fn(string $message) => expect($message)->toBe('Email must be a valid email address') + fn(string $message) => expect($message)->toBe('Email must be a valid email address'), )); test('Scenario #3', catchMessage( fn() => v::key('email', v::email())->assert($input), - fn(string $message) => expect($message)->toBe('`.email` must be a valid email address') + fn(string $message) => expect($message)->toBe('`.email` must be a valid email address'), )); diff --git a/tests/feature/Transformers/PrefixTest.php b/tests/feature/Transformers/PrefixTest.php index 2aeab3b9..8184136f 100644 --- a/tests/feature/Transformers/PrefixTest.php +++ b/tests/feature/Transformers/PrefixTest.php @@ -14,7 +14,7 @@ test('Key', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be equal to 12') ->and($fullMessage)->toBe('- `.foo` must be equal to 12') - ->and($messages)->toBe(['foo' => '`.foo` must be equal to 12']) + ->and($messages)->toBe(['foo' => '`.foo` must be equal to 12']), )); test('Length', catchAll( @@ -22,7 +22,7 @@ test('Length', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The length of "foo" must be greater than 3') ->and($fullMessage)->toBe('- The length of "foo" must be greater than 3') - ->and($messages)->toBe(['lengthGreaterThan' => 'The length of "foo" must be greater than 3']) + ->and($messages)->toBe(['lengthGreaterThan' => 'The length of "foo" must be greater than 3']), )); test('Max', catchAll( @@ -30,7 +30,7 @@ test('Max', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The maximum of `[1, 2, 3, 4]` must be an odd number') ->and($fullMessage)->toBe('- The maximum of `[1, 2, 3, 4]` must be an odd number') - ->and($messages)->toBe(['maxOdd' => 'The maximum of `[1, 2, 3, 4]` must be an odd number']) + ->and($messages)->toBe(['maxOdd' => 'The maximum of `[1, 2, 3, 4]` must be an odd number']), )); test('Min', catchAll( @@ -38,7 +38,7 @@ test('Min', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('The minimum of `[1, 2, 3]` must be an even number') ->and($fullMessage)->toBe('- The minimum of `[1, 2, 3]` must be an even number') - ->and($messages)->toBe(['minEven' => 'The minimum of `[1, 2, 3]` must be an even number']) + ->and($messages)->toBe(['minEven' => 'The minimum of `[1, 2, 3]` must be an even number']), )); test('Not', catchAll( @@ -46,7 +46,7 @@ test('Not', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('2 must not be between 1 and 3') ->and($fullMessage)->toBe('- 2 must not be between 1 and 3') - ->and($messages)->toBe(['notBetween' => '2 must not be between 1 and 3']) + ->and($messages)->toBe(['notBetween' => '2 must not be between 1 and 3']), )); test('NullOr', catchAll( @@ -54,7 +54,7 @@ test('NullOr', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"string" must be a boolean or must be null') ->and($fullMessage)->toBe('- "string" must be a boolean or must be null') - ->and($messages)->toBe(['nullOrBoolType' => '"string" must be a boolean or must be null']) + ->and($messages)->toBe(['nullOrBoolType' => '"string" must be a boolean or must be null']), )); test('Property', catchAll( @@ -62,7 +62,7 @@ test('Property', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('`.foo` must be between 1 and 3') ->and($fullMessage)->toBe('- `.foo` must be between 1 and 3') - ->and($messages)->toBe(['foo' => '`.foo` must be between 1 and 3']) + ->and($messages)->toBe(['foo' => '`.foo` must be between 1 and 3']), )); test('UndefOr', catchAll( @@ -70,5 +70,5 @@ test('UndefOr', catchAll( fn(string $message, string $fullMessage, array $messages) => expect() ->and($message)->toBe('"string" must be a URL or must be undefined') ->and($fullMessage)->toBe('- "string" must be a URL or must be undefined') - ->and($messages)->toBe(['undefOrUrl' => '"string" must be a URL or must be undefined']) + ->and($messages)->toBe(['undefOrUrl' => '"string" must be a URL or must be undefined']), )); diff --git a/tests/feature/TranslatorTest.php b/tests/feature/TranslatorTest.php index ac6c98b9..a8fe80d5 100644 --- a/tests/feature/TranslatorTest.php +++ b/tests/feature/TranslatorTest.php @@ -29,7 +29,7 @@ test('Various translations', catchFullMessage( - `[]` deve ser uma string - O comprimento de `[]` deve possuir de 2 a 15 caracteres - `[]` deve ser um número de telefone válido para o país Estados Unidos - FULL_MESSAGE) + FULL_MESSAGE), )); test('DateTimeDiff', catchMessage( @@ -42,7 +42,7 @@ test('DateTimeDiff', catchMessage( v::dateTimeDiff('years', v::equals(2))->assert('1972-02-09'); }, - fn(string $message) => expect($message)->toBe('O número de anos entre agora e "1972-02-09" deve ser igual a 2') + fn(string $message) => expect($message)->toBe('O número de anos entre agora e "1972-02-09" deve ser igual a 2'), )); test('Using "listOr"', catchMessage( @@ -54,7 +54,7 @@ test('Using "listOr"', catchMessage( v::templated(v::in(['Respect', 'Validation']), 'Your name must be {{haystack|listOr}}')->assert(''); }, - fn(string $message) => expect($message)->toBe('Seu nome deve ser "Respect" ou "Validation"') + fn(string $message) => expect($message)->toBe('Seu nome deve ser "Respect" ou "Validation"'), )); test('Using "listAnd"', catchMessage( @@ -66,5 +66,5 @@ test('Using "listAnd"', catchMessage( v::templated(v::in(['Respect', 'Validation']), '{{haystack|listAnd}} are the only possible names')->assert(''); }, - fn(string $message) => expect($message)->toBe('"Respect" e "Validation" são os únicos nomes possíveis') + fn(string $message) => expect($message)->toBe('"Respect" e "Validation" são os únicos nomes possíveis'), )); diff --git a/tests/feature/ValidationExceptionStackTraceTest.php b/tests/feature/ValidationExceptionStackTraceTest.php index 6098c63e..530b6483 100644 --- a/tests/feature/ValidationExceptionStackTraceTest.php +++ b/tests/feature/ValidationExceptionStackTraceTest.php @@ -54,11 +54,12 @@ test('Should go not overwrite file and line when it runs out of choices', functi array_filter( array_map( fn($trace) => $trace['file'] ?? null, - debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) - ) - ) + debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), + ), + ), ); $trace[] = __FILE__; + throw new ValidationException('message', 'fullMessage', ['id' => 'message'], $trace); } catch (ValidationException $e) { expect($e->getFile())->toBe(__FILE__); diff --git a/tests/fixtures/data-provider.php b/tests/fixtures/data-provider.php index e3053f38..6518856f 100644 --- a/tests/fixtures/data-provider.php +++ b/tests/fixtures/data-provider.php @@ -144,8 +144,9 @@ return [ 'tags' => ['objectType', 'withAttributes'], ], 'anonymous class' => [ - 'value' => [new class { - }, + 'value' => [ + new class { + }, ], 'tags' => ['objectType', 'withoutAttributes'], ], @@ -168,6 +169,7 @@ return [ if ($resource === false) { throw new RuntimeException('Failed to create temporary file.'); } + fclose($resource); return $resource; diff --git a/tests/library/Builders/ResultBuilder.php b/tests/library/Builders/ResultBuilder.php index 8b302180..16394887 100644 --- a/tests/library/Builders/ResultBuilder.php +++ b/tests/library/Builders/ResultBuilder.php @@ -26,13 +26,13 @@ final class ResultBuilder /** @var array */ private array $parameters = []; - private ?string $name = null; + private string|null $name = null; - private ?string $id = null; + private string|null $id = null; private Rule $rule; - private ?Result $adjacent = null; + private Result|null $adjacent = null; /** @var array */ private array $children = []; @@ -55,7 +55,7 @@ final class ResultBuilder $this->id, $this->adjacent, null, - ...$this->children + ...$this->children, ); } diff --git a/tests/library/DataProvider.php b/tests/library/DataProvider.php index 3bde715b..2199a655 100644 --- a/tests/library/DataProvider.php +++ b/tests/library/DataProvider.php @@ -17,16 +17,12 @@ use function array_filter; use function array_intersect; use function array_map; -/** - * @implements IteratorAggregate> - */ +/** @implements IteratorAggregate> */ final class DataProvider implements IteratorAggregate { - /** - * @param array $data - */ + /** @param array $data */ public function __construct( - private readonly array $data + private readonly array $data, ) { } @@ -34,7 +30,7 @@ final class DataProvider implements IteratorAggregate { return new self(array_filter( $this->data, - static fn($value) => array_intersect($tags, $value['tags']) === $tags + static fn($value) => array_intersect($tags, $value['tags']) === $tags, )); } @@ -42,7 +38,7 @@ final class DataProvider implements IteratorAggregate { return new self(array_filter( $this->data, - static fn($value) => array_intersect($tags, $value['tags']) !== [] + static fn($value) => array_intersect($tags, $value['tags']) !== [], )); } @@ -50,13 +46,11 @@ final class DataProvider implements IteratorAggregate { return new self(array_filter( $this->data, - static fn($value) => array_intersect($tags, $value['tags']) === [] + static fn($value) => array_intersect($tags, $value['tags']) === [], )); } - /** - * @return Traversable> - */ + /** @return Traversable> */ public function getIterator(): Traversable { return new ArrayIterator(array_map(static fn(array $value) => $value['value'], $this->data)); diff --git a/tests/library/Message/TestingMessageRenderer.php b/tests/library/Message/TestingMessageRenderer.php index 4ea23ddd..4e0da72e 100644 --- a/tests/library/Message/TestingMessageRenderer.php +++ b/tests/library/Message/TestingMessageRenderer.php @@ -15,7 +15,7 @@ use Respect\Validation\Result; final class TestingMessageRenderer implements Renderer { - public function render(Result $result, Translator $translator, ?string $template = null): string + public function render(Result $result, Translator $translator, string|null $template = null): string { return $template ?? $result->template; } diff --git a/tests/library/Message/TestingStringifier.php b/tests/library/Message/TestingStringifier.php index d605a370..1b628ff6 100644 --- a/tests/library/Message/TestingStringifier.php +++ b/tests/library/Message/TestingStringifier.php @@ -16,7 +16,7 @@ use function sprintf; final class TestingStringifier implements Stringifier { - public function stringify(mixed $raw, int $depth): ?string + public function stringify(mixed $raw, int $depth): string|null { return sprintf('<%s:%d>', print_r($raw, true), $depth); } diff --git a/tests/library/RuleTestCase.php b/tests/library/RuleTestCase.php index 9c5215f1..dbbb8d5f 100644 --- a/tests/library/RuleTestCase.php +++ b/tests/library/RuleTestCase.php @@ -22,7 +22,6 @@ abstract class RuleTestCase extends TestCase * as the first element and an input in which the validation SHOULD pass. * * @return iterable - *@api */ abstract public static function providerForValidInput(): iterable; @@ -33,7 +32,6 @@ abstract class RuleTestCase extends TestCase * as the first element and an input in which the validation SHOULD NOT pass. * * @return iterable - *@api */ abstract public static function providerForInvalidInput(): iterable; diff --git a/tests/library/Rules/Core/ConcreteFilteredString.php b/tests/library/Rules/Core/ConcreteFilteredString.php index 29460c35..14b41d63 100644 --- a/tests/library/Rules/Core/ConcreteFilteredString.php +++ b/tests/library/Rules/Core/ConcreteFilteredString.php @@ -13,7 +13,7 @@ use Respect\Validation\Rules\Core\FilteredString; final class ConcreteFilteredString extends FilteredString { - public ?string $lastFilteredInput = null; + public string|null $lastFilteredInput = null; protected function isValid(string $input): bool { diff --git a/tests/library/Rules/AbstractClass.php b/tests/library/Rules/MyAbstractClass.php similarity index 81% rename from tests/library/Rules/AbstractClass.php rename to tests/library/Rules/MyAbstractClass.php index 01f7f8bc..6bf6eaff 100644 --- a/tests/library/Rules/AbstractClass.php +++ b/tests/library/Rules/MyAbstractClass.php @@ -11,6 +11,6 @@ namespace Respect\Validation\Test\Rules; use Respect\Validation\Rule; -abstract class AbstractClass implements Rule +abstract class MyAbstractClass implements Rule { } diff --git a/tests/library/Rules/Stub.php b/tests/library/Rules/Stub.php index 832868fc..48a75dce 100644 --- a/tests/library/Rules/Stub.php +++ b/tests/library/Rules/Stub.php @@ -47,7 +47,7 @@ final class Stub extends Simple public static function any(int $expectedCount): self { - return new self(...array_map(static fn () => rand(0, 1) == 1, array_fill(0, $expectedCount, null))); + return new self(...array_map(static fn() => rand(0, 1) == 1, array_fill(0, $expectedCount, null))); } public static function fail(int $expectedCount): self diff --git a/tests/library/Stubs/CountableStub.php b/tests/library/Stubs/CountableStub.php index 494180b2..0d30eeba 100644 --- a/tests/library/Stubs/CountableStub.php +++ b/tests/library/Stubs/CountableStub.php @@ -13,17 +13,13 @@ use Countable; final class CountableStub implements Countable { - /** - * @param positive-int $value - */ + /** @param positive-int $value */ public function __construct( - private readonly int $value + private readonly int $value, ) { } - /** - * @return positive-int - */ + /** @return positive-int */ public function count(): int { return $this->value; diff --git a/tests/library/Stubs/MyValidator.php b/tests/library/Stubs/MyValidator.php index 3a328ad0..c994a1d3 100644 --- a/tests/library/Stubs/MyValidator.php +++ b/tests/library/Stubs/MyValidator.php @@ -24,6 +24,7 @@ final class MyValidator } catch (ValidationException $exception) { // This is a workaround to avoid changing exceptions that are thrown in other places. ValidatorDefaults::setIgnoredBacktracePaths(...$originalIgnoredBacktracePaths); + throw $exception; } } diff --git a/tests/library/Stubs/StreamStub.php b/tests/library/Stubs/StreamStub.php index b5cda16c..4df2e4e6 100644 --- a/tests/library/Stubs/StreamStub.php +++ b/tests/library/Stubs/StreamStub.php @@ -19,7 +19,7 @@ final class StreamStub implements StreamInterface private bool $isWritable = true; - private ?int $size = null; + private int|null $size = null; public static function create(): self { @@ -62,7 +62,7 @@ final class StreamStub implements StreamInterface return null; } - public function getSize(): ?int + public function getSize(): int|null { return $this->size; } diff --git a/tests/library/Stubs/ToStringStub.php b/tests/library/Stubs/ToStringStub.php index 7aeb8a24..2eb5e134 100644 --- a/tests/library/Stubs/ToStringStub.php +++ b/tests/library/Stubs/ToStringStub.php @@ -12,7 +12,7 @@ namespace Respect\Validation\Test\Stubs; final class ToStringStub { public function __construct( - private readonly string $value + private readonly string $value, ) { } diff --git a/tests/library/Stubs/UploadedFileStub.php b/tests/library/Stubs/UploadedFileStub.php index a334023a..480cfa42 100644 --- a/tests/library/Stubs/UploadedFileStub.php +++ b/tests/library/Stubs/UploadedFileStub.php @@ -16,7 +16,7 @@ use const UPLOAD_ERR_OK; final class UploadedFileStub implements UploadedFileInterface { - private ?int $size = null; + private int|null $size = null; public static function create(): self { @@ -40,7 +40,7 @@ final class UploadedFileStub implements UploadedFileInterface { } - public function getSize(): ?int + public function getSize(): int|null { return $this->size; } @@ -50,12 +50,12 @@ final class UploadedFileStub implements UploadedFileInterface return UPLOAD_ERR_OK; } - public function getClientFilename(): ?string + public function getClientFilename(): string|null { return null; } - public function getClientMediaType(): ?string + public function getClientMediaType(): string|null { return null; } diff --git a/tests/library/Stubs/WithAttributes.php b/tests/library/Stubs/WithAttributes.php index 4f199648..2812225e 100644 --- a/tests/library/Stubs/WithAttributes.php +++ b/tests/library/Stubs/WithAttributes.php @@ -24,10 +24,10 @@ final class WithAttributes #[Rule\DateTimeDiff('years', new Rule\LessThanOrEqual(25))] public string $birthdate, #[Rule\Email] - public ?string $email = null, + public string|null $email = null, #[Rule\Phone] - public ?string $phone = null, - public ?string $address = null, + public string|null $phone = null, + public string|null $address = null, ) { } } diff --git a/tests/library/Stubs/WithProperties.php b/tests/library/Stubs/WithProperties.php index 864e0e72..6d0c54f3 100644 --- a/tests/library/Stubs/WithProperties.php +++ b/tests/library/Stubs/WithProperties.php @@ -11,9 +11,9 @@ namespace Respect\Validation\Test\Stubs; final class WithProperties { - public const PUBLIC_VALUE = 'public'; - public const PROTECTED_VALUE = 'protected'; - public const PRIVATE_VALUE = 'private'; + public const string PUBLIC_VALUE = 'public'; + public const string PROTECTED_VALUE = 'protected'; + public const string PRIVATE_VALUE = 'private'; public string $public = self::PUBLIC_VALUE; diff --git a/tests/library/Stubs/WithStaticProperties.php b/tests/library/Stubs/WithStaticProperties.php index 2701112f..f1a448ab 100644 --- a/tests/library/Stubs/WithStaticProperties.php +++ b/tests/library/Stubs/WithStaticProperties.php @@ -11,9 +11,9 @@ namespace Respect\Validation\Test\Stubs; final class WithStaticProperties { - public const PUBLIC_VALUE = 'public'; - public const PROTECTED_VALUE = 'protected'; - public const PRIVATE_VALUE = 'private'; + public const string PUBLIC_VALUE = 'public'; + public const string PROTECTED_VALUE = 'protected'; + public const string PRIVATE_VALUE = 'private'; public static string $public = self::PUBLIC_VALUE; diff --git a/tests/library/TestCase.php b/tests/library/TestCase.php index 0c1cca50..e3b18407 100644 --- a/tests/library/TestCase.php +++ b/tests/library/TestCase.php @@ -26,7 +26,7 @@ use function substr; abstract class TestCase extends PHPUnitTestCase { - public static function fixture(?string $filename = null): string + public static function fixture(string|null $filename = null): string { $parts = [(string) realpath(__DIR__ . '/../fixtures')]; if ($filename !== null) { @@ -46,8 +46,8 @@ abstract class TestCase extends PHPUnitTestCase '%s should pass with input %s and parameters %s', substr((string) strrchr($rule::class, '\\'), 1), stringify($input), - stringify($result->parameters) - ) + stringify($result->parameters), + ), ); } @@ -61,8 +61,8 @@ abstract class TestCase extends PHPUnitTestCase '%s should fail with input %s and parameters %s', substr((string) strrchr($rule::class, '\\'), 1), stringify($input), - stringify($result->parameters) - ) + stringify($result->parameters), + ), ); } diff --git a/tests/unit/FactoryTest.php b/tests/unit/FactoryTest.php index c8011505..006b0cb4 100644 --- a/tests/unit/FactoryTest.php +++ b/tests/unit/FactoryTest.php @@ -14,19 +14,20 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Test; use Respect\Validation\Exceptions\ComponentException; use Respect\Validation\Exceptions\InvalidClassException; -use Respect\Validation\Test\Rules\AbstractClass; use Respect\Validation\Test\Rules\Invalid; +use Respect\Validation\Test\Rules\MyAbstractClass; use Respect\Validation\Test\Rules\Stub; use Respect\Validation\Test\Rules\Valid; use Respect\Validation\Test\TestCase; +use function assert; use function sprintf; #[Group('core')] #[CoversClass(Factory::class)] final class FactoryTest extends TestCase { - private const TEST_RULES_NAMESPACE = 'Respect\\Validation\\Test\\Rules'; + private const string TEST_RULES_NAMESPACE = 'Respect\\Validation\\Test\\Rules'; #[Test] public function shouldCreateRuleByNameBasedOnNamespace(): void @@ -53,8 +54,8 @@ final class FactoryTest extends TestCase $constructorArguments = [true, false, true, false]; $factory = (new Factory())->withRuleNamespace(self::TEST_RULES_NAMESPACE); - /** @var Stub $rule */ $rule = $factory->rule('stub', $constructorArguments); + assert($rule instanceof Stub); self::assertSame($constructorArguments, $rule->validations); } @@ -76,9 +77,9 @@ final class FactoryTest extends TestCase $factory = (new Factory())->withRuleNamespace(self::TEST_RULES_NAMESPACE); $this->expectException(InvalidClassException::class); - $this->expectExceptionMessage(sprintf('"%s" must be instantiable', AbstractClass::class)); + $this->expectExceptionMessage(sprintf('"%s" must be instantiable', MyAbstractClass::class)); - $factory->rule('abstractClass'); + $factory->rule('myAbstractClass'); } #[Test] diff --git a/tests/unit/Helpers/CanValidateDateTimeTest.php b/tests/unit/Helpers/CanValidateDateTimeTest.php index 7d81617a..12163219 100644 --- a/tests/unit/Helpers/CanValidateDateTimeTest.php +++ b/tests/unit/Helpers/CanValidateDateTimeTest.php @@ -33,9 +33,7 @@ final class CanValidateDateTimeTest extends TestCase self::assertFalse($this->isDateTime($format, $value)); } - /** - * @return mixed[][] - */ + /** @return mixed[][] */ public static function providerForValidDateTime(): array { return [ @@ -50,9 +48,7 @@ final class CanValidateDateTimeTest extends TestCase ]; } - /** - * @return mixed[][] - */ + /** @return mixed[][] */ public static function providerForInvalidDateTime(): array { return [ diff --git a/tests/unit/Message/StandardFormatter/ArrayProvider.php b/tests/unit/Message/StandardFormatter/ArrayProvider.php index 695faa91..7a906765 100644 --- a/tests/unit/Message/StandardFormatter/ArrayProvider.php +++ b/tests/unit/Message/StandardFormatter/ArrayProvider.php @@ -91,9 +91,7 @@ trait ArrayProvider [ '__root__' => 'Parent custom', '1st' => '1st custom', - '2nd' => [ - '2nd_1st' => '2nd > 1st custom', - ], + '2nd' => ['2nd_1st' => '2nd > 1st custom'], '3rd' => '3rd custom', ], ], @@ -108,9 +106,7 @@ trait ArrayProvider [ '__root__' => 'Parent custom', '1st' => '1st custom', - '2nd' => [ - '2nd_2nd' => '2nd > 2nd not shown', - ], + '2nd' => ['2nd_2nd' => '2nd > 2nd not shown'], '3rd' => '3rd custom', ], ], @@ -180,9 +176,7 @@ trait ArrayProvider [ '__root__' => 'Parent custom', '1st' => '1st custom', - '2nd' => [ - '2nd_2nd' => '2nd > 2nd custom', - ], + '2nd' => ['2nd_2nd' => '2nd > 2nd custom'], '3rd' => '3rd custom', ], ], diff --git a/tests/unit/Message/StandardFormatter/FullProvider.php b/tests/unit/Message/StandardFormatter/FullProvider.php index f92cfc4f..34977a52 100644 --- a/tests/unit/Message/StandardFormatter/FullProvider.php +++ b/tests/unit/Message/StandardFormatter/FullProvider.php @@ -31,7 +31,7 @@ trait FullProvider ], 'with single-level children, without templates' => [ self::singleLevelChildrenMessage(), - << [ self::singleLevelChildrenMessage(), - << [ self::singleLevelChildrenMessage(), - << [ self::singleLevelChildrenMessage(), '- Parent custom', - [ - 'parent' => 'Parent custom', - ], + ['parent' => 'Parent custom'], ], 'with single-nested child, without templates' => [ self::multiLevelChildrenWithSingleNestedChildMessage(), - << [ self::multiLevelChildrenWithSingleNestedChildMessage(), - << [ self::multiLevelChildrenWithSingleNestedChildMessage(), - << [ '__root__' => 'Parent custom', '1st' => '1st custom', - '2nd' => [ - '2nd_2nd' => '2nd > 2nd not shown', - ], + '2nd' => ['2nd_2nd' => '2nd > 2nd not shown'], '3rd' => '3rd custom', ], ], ], 'with single-nested child, with overwritten templates' => [ self::multiLevelChildrenWithSingleNestedChildMessage(), - << [ self::multiLevelChildrenWithMultiNestedChildrenMessage(), - << [ self::multiLevelChildrenWithMultiNestedChildrenMessage(), - << [ self::multiLevelChildrenWithMultiNestedChildrenMessage(), - << [ '__root__' => 'Parent custom', '1st' => '1st custom', - '2nd' => [ - '2nd_2nd' => '2nd > 2nd custom', - ], + '2nd' => ['2nd_2nd' => '2nd > 2nd custom'], '3rd' => '3rd custom', ], ], ], 'with multi-nested children, with overwritten templates' => [ self::multiLevelChildrenWithMultiNestedChildrenMessage(), - << [ self::singleLevelChildrenWithSameId(), - << [ self::singleLevelChildrenWithSameId(), - << [ self::singleLevelChildrenWithSameId(), - << [ self::multiLevelChildrenWithSiblingsThatHaveOnlyOneChild(), - << [ self::multiLevelChildrenWithSiblingsThatHaveOnlyOneChild(), - << [ self::multiLevelChildrenWithSiblingsThatHaveMoreThanOneChild(), - <<id('1st')->template('__1st_original__')->build(), (new ResultBuilder())->id('2nd')->template('__2nd_original__') ->children( - (new ResultBuilder())->id('2nd_1st')->template('__2nd_1st_original__')->build() + (new ResultBuilder())->id('2nd_1st')->template('__2nd_1st_original__')->build(), ) ->build(), (new ResultBuilder())->id('3rd')->template('__3rd_original__')->build(), @@ -77,15 +77,22 @@ trait ResultCreator (new ResultBuilder())->id('1st') ->template('__1st_original__') ->children( - (new ResultBuilder())->id('1st_1st')->template('__1st_1st_original__')->build(), - (new ResultBuilder())->id('1st_2nd')->template('__1st_2nd_original__')->hasPassed(true)->build() + (new ResultBuilder()) + ->id('1st_1st') + ->template('__1st_1st_original__') + ->build(), + (new ResultBuilder()) + ->id('1st_2nd') + ->template('__1st_2nd_original__') + ->hasPassed(true) + ->build(), ) ->build(), (new ResultBuilder()) ->id('2nd') ->template('__2nd_original__') ->children( - (new ResultBuilder())->id('2nd_1st')->template('__2nd_1st_original__')->build() + (new ResultBuilder())->id('2nd_1st')->template('__2nd_1st_original__')->build(), ) ->build(), ) @@ -100,7 +107,7 @@ trait ResultCreator ->template('__1st_original__') ->children( (new ResultBuilder())->id('1st_1st')->template('__1st_1st_original__')->build(), - (new ResultBuilder())->id('1st_2nd')->template('__1st_2nd_original__')->build() + (new ResultBuilder())->id('1st_2nd')->template('__1st_2nd_original__')->build(), ) ->build(), (new ResultBuilder()) @@ -108,7 +115,7 @@ trait ResultCreator ->template('__2nd_original__') ->children( (new ResultBuilder())->id('2nd_1st')->template('__2nd_1st_original__')->build(), - (new ResultBuilder())->id('2nd_2nd')->template('__2nd_2nd_original__')->build() + (new ResultBuilder())->id('2nd_2nd')->template('__2nd_2nd_original__')->build(), ) ->build(), (new ResultBuilder())->id('3nd')->template('__3rd_original__')->build(), diff --git a/tests/unit/Message/StandardRendererTest.php b/tests/unit/Message/StandardRendererTest.php index 41eccd04..0d77cda2 100644 --- a/tests/unit/Message/StandardRendererTest.php +++ b/tests/unit/Message/StandardRendererTest.php @@ -61,7 +61,7 @@ final class StandardRendererTest extends TestCase self::assertSame( 'Will replace ' . $stringifier->stringify($value, 0), - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -82,7 +82,7 @@ final class StandardRendererTest extends TestCase self::assertSame( sprintf('Will replace %s and 0.1', $stringifier->stringify($value, 0)), - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -103,7 +103,7 @@ final class StandardRendererTest extends TestCase self::assertSame( sprintf('Will replace %s and 0', $stringifier->stringify($value, 0)), - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -125,7 +125,7 @@ final class StandardRendererTest extends TestCase self::assertSame( sprintf('Will replace %s and %s', $stringifier->stringify($value, 0), $translation), - $renderer->render($result, new ArrayTranslator([$value => $translation])) + $renderer->render($result, new ArrayTranslator([$value => $translation])), ); } @@ -145,7 +145,7 @@ final class StandardRendererTest extends TestCase self::assertSame( sprintf('Will replace %s', $value), - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -165,7 +165,7 @@ final class StandardRendererTest extends TestCase self::assertSame( sprintf('Will replace %s', $stringifier->stringify($value, 0)), - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -183,7 +183,7 @@ final class StandardRendererTest extends TestCase self::assertSame( 'Will replace ' . $name, - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -203,7 +203,7 @@ final class StandardRendererTest extends TestCase self::assertSame( sprintf('Will replace %s', $stringifier->stringify($input, 0)), - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -223,7 +223,7 @@ final class StandardRendererTest extends TestCase self::assertSame( sprintf('Will replace %s', $stringifier->stringify($input, 0)), - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -244,7 +244,7 @@ final class StandardRendererTest extends TestCase self::assertSame( sprintf('Will replace %s', $parameterNameValue), - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -265,7 +265,7 @@ final class StandardRendererTest extends TestCase self::assertSame( sprintf('Will replace %s', $stringifier->stringify($input, 0)), - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -307,7 +307,7 @@ final class StandardRendererTest extends TestCase self::assertSame( sprintf('%s must be a valid stub', $stringifier->stringify($result->input, 0)), - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -321,7 +321,7 @@ final class StandardRendererTest extends TestCase self::assertSame( sprintf('%s must not be a valid stub', $stringifier->stringify($result->input, 0)), - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } @@ -334,7 +334,7 @@ final class StandardRendererTest extends TestCase self::assertSame( $result->template, - $renderer->render($result, new DummyTranslator()) + $renderer->render($result, new DummyTranslator()), ); } diff --git a/tests/unit/Rules/AlwaysInvalidTest.php b/tests/unit/Rules/AlwaysInvalidTest.php index d18950fa..97fb1fac 100644 --- a/tests/unit/Rules/AlwaysInvalidTest.php +++ b/tests/unit/Rules/AlwaysInvalidTest.php @@ -28,9 +28,7 @@ final class AlwaysInvalidTest extends TestCase self::assertFalse($rule->evaluate($input)->hasPassed); } - /** - * @return mixed[][] - */ + /** @return mixed[][] */ public static function providerForInvalidInput(): iterable { return [ diff --git a/tests/unit/Rules/AlwaysValidTest.php b/tests/unit/Rules/AlwaysValidTest.php index 626dac7d..7c6dcbee 100644 --- a/tests/unit/Rules/AlwaysValidTest.php +++ b/tests/unit/Rules/AlwaysValidTest.php @@ -28,9 +28,7 @@ final class AlwaysValidTest extends TestCase self::assertTrue($rule->evaluate($input)->hasPassed); } - /** - * @return mixed[][] - */ + /** @return mixed[][] */ public static function providerForValidInput(): iterable { return [ diff --git a/tests/unit/Rules/AttributesTest.php b/tests/unit/Rules/AttributesTest.php index 748cc719..08de9c18 100644 --- a/tests/unit/Rules/AttributesTest.php +++ b/tests/unit/Rules/AttributesTest.php @@ -58,7 +58,7 @@ final class AttributesTest extends TestCase '2020-06-23', 'john.doe@gmail.com', '+31206241111', - 'Amstel 1 1011 PN AMSTERDAM Noord-Holland' + 'Amstel 1 1011 PN AMSTERDAM Noord-Holland', ), ], 'Only required' => [new WithAttributes('Jane Doe', '2017-11-30', 'janedoe@yahoo.com')], diff --git a/tests/unit/Rules/BetweenExclusiveTest.php b/tests/unit/Rules/BetweenExclusiveTest.php index e28499c1..113bbb1c 100644 --- a/tests/unit/Rules/BetweenExclusiveTest.php +++ b/tests/unit/Rules/BetweenExclusiveTest.php @@ -26,7 +26,7 @@ final class BetweenExclusiveTest extends TestCase public function minimumValueShouldNotBeGreaterThanMaximumValue(): void { $this->expectExceptionObject( - new InvalidRuleConstructorException('Minimum cannot be less than or equals to maximum') + new InvalidRuleConstructorException('Minimum cannot be less than or equals to maximum'), ); new BetweenExclusive(10, 5); @@ -36,7 +36,7 @@ final class BetweenExclusiveTest extends TestCase public function minimumValueShouldNotBeEqualsToMaximumValue(): void { $this->expectExceptionObject( - new InvalidRuleConstructorException('Minimum cannot be less than or equals to maximum') + new InvalidRuleConstructorException('Minimum cannot be less than or equals to maximum'), ); new BetweenExclusive(5, 5); diff --git a/tests/unit/Rules/ConsonantTest.php b/tests/unit/Rules/ConsonantTest.php index 5ed19264..fd789f4c 100644 --- a/tests/unit/Rules/ConsonantTest.php +++ b/tests/unit/Rules/ConsonantTest.php @@ -36,7 +36,8 @@ final class ConsonantTest extends RuleTestCase 'String "zbcxwyrspq"' => [$consonant, 'zbcxwyrspq'], 'Ignoring characters "!@#$%^&*(){}"' => [new Consonant('!@#$%^&*(){}'), '!@#$%^&*(){} bc dfg'], 'Ignoring characters "[]?+=/\\-_|"\',<>."' => [ - new Consonant('[]?+=/\\-_|"\',<>.'), "[]?+=/\\-_|\"',<>. \t \n bc dfg", + new Consonant('[]?+=/\\-_|"\',<>.'), + "[]?+=/\\-_|\"',<>. \t \n bc dfg", ], ]; } diff --git a/tests/unit/Rules/Core/FilteredStringTest.php b/tests/unit/Rules/Core/FilteredStringTest.php index 4092d419..84f1ea0e 100644 --- a/tests/unit/Rules/Core/FilteredStringTest.php +++ b/tests/unit/Rules/Core/FilteredStringTest.php @@ -110,7 +110,7 @@ final class FilteredStringTest extends TestCase public function itShouldFilterAdditionalCharactersWhenValidatingInput( string $additionalChars, string $input, - string $expectedInput + string $expectedInput, ): void { $rule = new ConcreteFilteredString($additionalChars); $rule->evaluate($input); diff --git a/tests/unit/Rules/CountryCodeTest.php b/tests/unit/Rules/CountryCodeTest.php index 062562c9..0f21ef4a 100644 --- a/tests/unit/Rules/CountryCodeTest.php +++ b/tests/unit/Rules/CountryCodeTest.php @@ -24,7 +24,7 @@ final class CountryCodeTest extends RuleTestCase { $this->expectException(InvalidRuleConstructorException::class); $this->expectExceptionMessage( - '"whatever" is not a valid set for ISO 3166-1 (Available: "alpha-2", "alpha-3", and "numeric")' + '"whatever" is not a valid set for ISO 3166-1 (Available: "alpha-2", "alpha-3", and "numeric")', ); // @phpstan-ignore-next-line diff --git a/tests/unit/Rules/CurrencyCodeTest.php b/tests/unit/Rules/CurrencyCodeTest.php index 9c34b6c7..b2c729b4 100644 --- a/tests/unit/Rules/CurrencyCodeTest.php +++ b/tests/unit/Rules/CurrencyCodeTest.php @@ -24,7 +24,7 @@ final class CurrencyCodeTest extends RuleTestCase { $this->expectException(InvalidRuleConstructorException::class); $this->expectExceptionMessage( - '"whatever" is not a valid set for ISO 4217 (Available: "alpha-3" and "numeric")' + '"whatever" is not a valid set for ISO 4217 (Available: "alpha-3" and "numeric")', ); // @phpstan-ignore-next-line diff --git a/tests/unit/Rules/DateTest.php b/tests/unit/Rules/DateTest.php index 9d701ca0..f207e630 100644 --- a/tests/unit/Rules/DateTest.php +++ b/tests/unit/Rules/DateTest.php @@ -31,9 +31,7 @@ final class DateTest extends RuleTestCase new Date($format); } - /** - * @return string[][] - */ + /** @return string[][] */ public static function validFormatsProvider(): array { return [ diff --git a/tests/unit/Rules/DateTimeDiffTest.php b/tests/unit/Rules/DateTimeDiffTest.php index c920cd28..111b913e 100644 --- a/tests/unit/Rules/DateTimeDiffTest.php +++ b/tests/unit/Rules/DateTimeDiffTest.php @@ -79,8 +79,8 @@ final class DateTimeDiffTest extends RuleTestCase 'invalid date', ], ] + array_map( - static fn (array $args): array => [new DateTimeDiff('years', Stub::fail(1)), new DateTimeImmutable()], - iterator_to_array(self::providerForNonScalarValues()) + static fn(array $args): array => [new DateTimeDiff('years', Stub::fail(1)), new DateTimeImmutable()], + iterator_to_array(self::providerForNonScalarValues()), ); } } diff --git a/tests/unit/Rules/DateTimeTest.php b/tests/unit/Rules/DateTimeTest.php index 0afa009b..577ce8ce 100644 --- a/tests/unit/Rules/DateTimeTest.php +++ b/tests/unit/Rules/DateTimeTest.php @@ -40,9 +40,7 @@ final class DateTimeTest extends RuleTestCase date_default_timezone_set($currentTimezone); } - /** - * @return mixed[][] - */ + /** @return mixed[][] */ public static function providerForDateTimeWithTimezone(): array { return [ diff --git a/tests/unit/Rules/FactorTest.php b/tests/unit/Rules/FactorTest.php index 2ac39e35..1a42477f 100644 --- a/tests/unit/Rules/FactorTest.php +++ b/tests/unit/Rules/FactorTest.php @@ -54,7 +54,7 @@ final class FactorTest extends RuleTestCase '6 is factor \'2\'' => [new Factor(6), '2'], '4 is factor 2.00' => [new Factor(4), 2.0], '-0 is factor -5.000000' => [new Factor(-0), -5.000000], - '-0 is factor (float) - mt_rand()' => [new Factor(-0), (float) - mt_rand()], + '-0 is factor (float) - mt_rand()' => [new Factor(-0), (float) -mt_rand()], ]; } diff --git a/tests/unit/Rules/IbanTest.php b/tests/unit/Rules/IbanTest.php index 11dff388..c113ddb8 100644 --- a/tests/unit/Rules/IbanTest.php +++ b/tests/unit/Rules/IbanTest.php @@ -20,6 +20,15 @@ use function extension_loaded; #[CoversClass(Iban::class)] final class IbanTest extends RuleTestCase { + protected function setUp(): void + { + if (extension_loaded('bcmath')) { + return; + } + + $this->markTestSkipped('You need bcmath to execute this test'); + } + /** @return iterable */ public static function providerForValidInput(): iterable { @@ -59,13 +68,4 @@ final class IbanTest extends RuleTestCase 'GermanydWrong' => [$sut, 'DE89 5000 5880 7742'], ]; } - - protected function setUp(): void - { - if (extension_loaded('bcmath')) { - return; - } - - $this->markTestSkipped('You need bcmath to execute this test'); - } } diff --git a/tests/unit/Rules/IpTest.php b/tests/unit/Rules/IpTest.php index 38ff30fc..26d730fb 100644 --- a/tests/unit/Rules/IpTest.php +++ b/tests/unit/Rules/IpTest.php @@ -25,6 +25,15 @@ use const FILTER_FLAG_NO_PRIV_RANGE; #[CoversClass(Ip::class)] final class IpTest extends RuleTestCase { + protected function setUp(): void + { + if (extension_loaded('bcmath')) { + return; + } + + $this->markTestSkipped('You need bcmath to execute this test'); + } + #[Test] #[DataProvider('providerForInvalidRanges')] public function invalidRangeShouldRaiseException(string $range): void @@ -34,9 +43,7 @@ final class IpTest extends RuleTestCase new Ip($range); } - /** - * @return string[][] - */ + /** @return string[][] */ public static function providerForInvalidRanges(): array { return [ @@ -100,13 +107,4 @@ final class IpTest extends RuleTestCase [new Ip('220.78.168.0/255.255.248.0'), '220.78.176.3'], ]; } - - protected function setUp(): void - { - if (extension_loaded('bcmath')) { - return; - } - - $this->markTestSkipped('You need bcmath to execute this test'); - } } diff --git a/tests/unit/Rules/KeySetTest.php b/tests/unit/Rules/KeySetTest.php index 14ca5143..c4e06df2 100644 --- a/tests/unit/Rules/KeySetTest.php +++ b/tests/unit/Rules/KeySetTest.php @@ -44,18 +44,22 @@ final class KeySetTest extends RuleTestCase new KeySet(new KeyExists('foo')), ['baz' => 'qux'], ]; + yield 'extra keys, failed rule' => [ new KeySet(new Key('foo', Stub::pass(1))), ['foo' => 'bar', 'baz' => 'qux'], ]; + yield 'missing key, failed rule' => [ new KeySet(new Key('foo', Stub::fail(1)), new KeyExists('bar')), ['foo' => 'bar', 'baz' => 'qux'], ]; + yield 'extra keys, with failing rule' => [ new KeySet(new Key('foo', Stub::fail(1))), ['foo' => 'bar', 'baz' => 'qux'], ]; + yield 'correct keys, with failing rule' => [new KeySet(new Key('foo', Stub::fail(1))), ['foo' => 'bar']]; } } diff --git a/tests/unit/Rules/LanguageCodeTest.php b/tests/unit/Rules/LanguageCodeTest.php index 6a360318..992f737a 100644 --- a/tests/unit/Rules/LanguageCodeTest.php +++ b/tests/unit/Rules/LanguageCodeTest.php @@ -24,7 +24,7 @@ final class LanguageCodeTest extends RuleTestCase { $this->expectException(InvalidRuleConstructorException::class); $this->expectExceptionMessage( - '"whatever" is not a valid set for ISO 639-3 (Available: "alpha-2" and "alpha-3")' + '"whatever" is not a valid set for ISO 639-3 (Available: "alpha-2" and "alpha-3")', ); // @phpstan-ignore-next-line diff --git a/tests/unit/Rules/LazyTest.php b/tests/unit/Rules/LazyTest.php index 14b539af..649fc38e 100644 --- a/tests/unit/Rules/LazyTest.php +++ b/tests/unit/Rules/LazyTest.php @@ -25,7 +25,7 @@ final class LazyTest extends TestCase public function itShouldThrowAnExceptionWhenRuleCreatorDoesNotReturnRule(): void { // @phpstan-ignore-next-line - $rule = new Lazy(static fn () => null); + $rule = new Lazy(static fn() => null); $this->expectException(ComponentException::class); $this->expectExceptionMessage('Lazy failed because it could not create the rule'); @@ -37,14 +37,14 @@ final class LazyTest extends TestCase #[DataProvider('providerForAnyValues')] public function itShouldInvalidInputWhenCreatedRuleFails(mixed $input): void { - self::assertInvalidInput(new Lazy(static fn ($creatorInput) => Stub::fail(1)), $input); + self::assertInvalidInput(new Lazy(static fn($creatorInput) => Stub::fail(1)), $input); } #[Test] #[DataProvider('providerForAnyValues')] public function itShouldValidInputWhenCreatedRulePasses(mixed $input): void { - self::assertValidInput(new Lazy(static fn ($creatorInput) => Stub::pass(1)), $input); + self::assertValidInput(new Lazy(static fn($creatorInput) => Stub::pass(1)), $input); } #[Test] @@ -53,7 +53,7 @@ final class LazyTest extends TestCase { $expected = Stub::fail(1)->evaluate($input); - $rule = new Lazy(static fn ($creatorInput) => Stub::fail(1)); + $rule = new Lazy(static fn($creatorInput) => Stub::fail(1)); $actual = $rule->evaluate($input); self::assertEquals($expected, $actual); diff --git a/tests/unit/Rules/NoTest.php b/tests/unit/Rules/NoTest.php index 5496f70d..bb6dc87b 100644 --- a/tests/unit/Rules/NoTest.php +++ b/tests/unit/Rules/NoTest.php @@ -26,6 +26,11 @@ final class NoTest extends RuleTestCase { private readonly string $locale; + protected function setUp(): void + { + $this->locale = (string) setlocale(LC_ALL, '0'); + } + #[Test] #[DataProvider('providerForValidInputWithLocale')] public function itShouldValidateInputAccordingToTheLocale(string $locale, string $input): void @@ -52,9 +57,7 @@ final class NoTest extends RuleTestCase self::assertInvalidInput(new No(true), $input); } - /** - * @return string[][] - */ + /** @return string[][] */ public static function providerForValidInputWithLocale(): array { return [ @@ -64,9 +67,7 @@ final class NoTest extends RuleTestCase ]; } - /** - * @return string[][] - */ + /** @return string[][] */ public static function providerForInvalidInputWithLocale(): array { return [ @@ -105,11 +106,6 @@ final class NoTest extends RuleTestCase ]; } - protected function setUp(): void - { - $this->locale = (string) setlocale(LC_ALL, '0'); - } - protected function tearDown(): void { setlocale(LC_ALL, $this->locale); diff --git a/tests/unit/Rules/NotTest.php b/tests/unit/Rules/NotTest.php index f6db1ff6..f98e2f7e 100644 --- a/tests/unit/Rules/NotTest.php +++ b/tests/unit/Rules/NotTest.php @@ -28,7 +28,7 @@ final class NotTest extends RuleTestCase self::assertEquals( $rule->evaluate('input'), - $wrapped->evaluate('input')->withPrefix('not')->withToggledModeAndValidation() + $wrapped->evaluate('input')->withPrefix('not')->withToggledModeAndValidation(), ); } diff --git a/tests/unit/Rules/TimeTest.php b/tests/unit/Rules/TimeTest.php index 01ff672e..2d35da05 100644 --- a/tests/unit/Rules/TimeTest.php +++ b/tests/unit/Rules/TimeTest.php @@ -31,9 +31,7 @@ final class TimeTest extends RuleTestCase new Time($format); } - /** - * @return mixed[][] - */ + /** @return mixed[][] */ public static function invalidFormatsProvider(): array { return [ diff --git a/tests/unit/Rules/UploadedTest.php b/tests/unit/Rules/UploadedTest.php index 1952e302..86c5f909 100644 --- a/tests/unit/Rules/UploadedTest.php +++ b/tests/unit/Rules/UploadedTest.php @@ -20,7 +20,7 @@ use SplFileInfo; #[CoversClass(Uploaded::class)] final class UploadedTest extends TestCase { - public const UPLOADED_FILENAME = 'uploaded.ext'; + public const string UPLOADED_FILENAME = 'uploaded.ext'; #[Test] public function itShouldValidateWhenFileIsUploadedAndTheInputIsString(): void diff --git a/tests/unit/Rules/UuidTest.php b/tests/unit/Rules/UuidTest.php index 8466655f..7f2eb186 100644 --- a/tests/unit/Rules/UuidTest.php +++ b/tests/unit/Rules/UuidTest.php @@ -29,7 +29,7 @@ use const PHP_INT_MIN; #[CoversClass(Uuid::class)] final class UuidTest extends RuleTestCase { - private const ALL_VERSIONS = [ + private const array ALL_VERSIONS = [ 1 => 'e4eaaaf2-d142-11e1-b3e4-080027620cdd', 2 => '000003e8-3702-21f0-9f00-325096b39f47', 3 => '11a38b9a-b3da-360f-9353-a5a725514269', @@ -71,18 +71,22 @@ final class UuidTest extends RuleTestCase new Uuid(), str_replace('-', '', $string), ]; + yield sprintf('default with UUID version %d object', $version) => [ new Uuid(), RamseyUuid::fromString($string), ]; + yield sprintf('expected version %1$d with UUID v%1$d string', $version) => [ new Uuid($version), $string, ]; + yield sprintf('expected version %1$d with unformatted UUID v%1$d string', $version) => [ new Uuid($version), str_replace('-', '', $string), ]; + yield sprintf('expected version %1$d with UUID v%1$d object', $version) => [ new Uuid($version), RamseyUuid::fromString($string), @@ -112,6 +116,7 @@ final class UuidTest extends RuleTestCase new Uuid($versionB), $string, ]; + yield sprintf('expected version %1$d with UUID version %2$d object', $versionA, $versionB) => [ new Uuid($versionB), RamseyUuid::fromString($string), diff --git a/tests/unit/Rules/YesTest.php b/tests/unit/Rules/YesTest.php index 9e6b8543..55e4f8b9 100644 --- a/tests/unit/Rules/YesTest.php +++ b/tests/unit/Rules/YesTest.php @@ -29,6 +29,11 @@ final class YesTest extends RuleTestCase { private readonly string $locale; + protected function setUp(): void + { + $this->locale = (string) setlocale(LC_ALL, '0'); + } + #[Test] #[DataProvider('providerForValidInputWithLocale')] public function itShouldValidateValidInputAccordingToTheLocale(string $locale, string $input): void @@ -55,9 +60,7 @@ final class YesTest extends RuleTestCase self::assertInvalidInput(new Yes(true), $input); } - /** - * @return string[][] - */ + /** @return string[][] */ public static function providerForValidInputWithLocale(): array { return [ @@ -67,9 +70,7 @@ final class YesTest extends RuleTestCase ]; } - /** - * @return string[][] - */ + /** @return string[][] */ public static function providerForInvalidInputWithLocale(): array { return [ @@ -111,11 +112,6 @@ final class YesTest extends RuleTestCase ]; } - protected function setUp(): void - { - $this->locale = (string) setlocale(LC_ALL, '0'); - } - protected function tearDown(): void { setlocale(LC_ALL, $this->locale); diff --git a/tests/unit/ValidatorTest.php b/tests/unit/ValidatorTest.php index 3833c2d7..d30ce858 100644 --- a/tests/unit/ValidatorTest.php +++ b/tests/unit/ValidatorTest.php @@ -165,9 +165,7 @@ final class ValidatorTest extends TestCase $validator->assert('whatever', $template); } - /** - * @return array}> - */ + /** @return array}> */ public static function providerForTemplates(): array { return [