From 1d6d005838124c5b50d43195f7d971be22948ead Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Tue, 7 Jan 2025 14:19:09 +0100 Subject: [PATCH] Make `Simple::isValid()` public There's no reason not to make this method public. It will actually be easier for users to test their rules when they extend this class if this method is public. --- library/Rules/AlwaysInvalid.php | 2 +- library/Rules/AlwaysValid.php | 2 +- library/Rules/ArrayType.php | 2 +- library/Rules/ArrayVal.php | 2 +- library/Rules/Base64.php | 2 +- library/Rules/BoolType.php | 2 +- library/Rules/BoolVal.php | 2 +- library/Rules/Bsn.php | 2 +- library/Rules/CallableType.php | 2 +- library/Rules/Callback.php | 2 +- library/Rules/Cnh.php | 2 +- library/Rules/Cnpj.php | 2 +- library/Rules/Core/Simple.php | 2 +- library/Rules/Countable.php | 2 +- library/Rules/Cpf.php | 2 +- library/Rules/Directory.php | 2 +- library/Rules/Email.php | 2 +- library/Rules/Even.php | 2 +- library/Rules/Executable.php | 2 +- library/Rules/Exists.php | 2 +- library/Rules/FalseVal.php | 2 +- library/Rules/Fibonacci.php | 2 +- library/Rules/File.php | 2 +- library/Rules/Finite.php | 2 +- library/Rules/FloatType.php | 2 +- library/Rules/FloatVal.php | 2 +- library/Rules/Hetu.php | 2 +- library/Rules/Iban.php | 2 +- library/Rules/Image.php | 2 +- library/Rules/Imei.php | 2 +- library/Rules/Infinite.php | 2 +- library/Rules/IntType.php | 2 +- library/Rules/IntVal.php | 2 +- library/Rules/Isbn.php | 2 +- library/Rules/IterableType.php | 2 +- library/Rules/IterableVal.php | 2 +- library/Rules/Json.php | 2 +- library/Rules/LeapDate.php | 2 +- library/Rules/LeapYear.php | 2 +- library/Rules/Lowercase.php | 2 +- library/Rules/Luhn.php | 2 +- library/Rules/MacAddress.php | 2 +- library/Rules/Negative.php | 2 +- library/Rules/NfeAccessKey.php | 2 +- library/Rules/Nif.php | 2 +- library/Rules/Nip.php | 2 +- library/Rules/NoWhitespace.php | 2 +- library/Rules/NotEmoji.php | 2 +- library/Rules/NullType.php | 2 +- library/Rules/Number.php | 2 +- library/Rules/NumericVal.php | 2 +- library/Rules/ObjectType.php | 2 +- library/Rules/Odd.php | 2 +- library/Rules/PerfectSquare.php | 2 +- library/Rules/Pesel.php | 2 +- library/Rules/PhpLabel.php | 2 +- library/Rules/Pis.php | 2 +- library/Rules/PolishIdCard.php | 2 +- library/Rules/PortugueseNif.php | 2 +- library/Rules/Positive.php | 2 +- library/Rules/PrimeNumber.php | 2 +- library/Rules/PublicDomainSuffix.php | 2 +- library/Rules/Readable.php | 2 +- library/Rules/ResourceType.php | 2 +- library/Rules/ScalarVal.php | 2 +- library/Rules/Slug.php | 2 +- library/Rules/StringType.php | 2 +- library/Rules/StringVal.php | 2 +- library/Rules/SymbolicLink.php | 2 +- library/Rules/Tld.php | 2 +- library/Rules/TrueVal.php | 2 +- library/Rules/Unique.php | 2 +- library/Rules/Uploaded.php | 2 +- library/Rules/Uppercase.php | 2 +- library/Rules/Version.php | 2 +- library/Rules/Writable.php | 2 +- library/Rules/Yes.php | 2 +- tests/feature/Issues/Issue1477Test.php | 2 +- tests/library/Rules/Core/ConcreteSimple.php | 2 +- tests/library/Rules/CustomRule.php | 2 +- tests/library/Rules/Stub.php | 2 +- tests/library/Rules/Valid.php | 2 +- 82 files changed, 82 insertions(+), 82 deletions(-) diff --git a/library/Rules/AlwaysInvalid.php b/library/Rules/AlwaysInvalid.php index 791cbe7d3..14ddba69f 100644 --- a/library/Rules/AlwaysInvalid.php +++ b/library/Rules/AlwaysInvalid.php @@ -28,7 +28,7 @@ final class AlwaysInvalid extends Simple { public const TEMPLATE_SIMPLE = '__simple__'; - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return false; } diff --git a/library/Rules/AlwaysValid.php b/library/Rules/AlwaysValid.php index dbca8bd44..da38ea43b 100644 --- a/library/Rules/AlwaysValid.php +++ b/library/Rules/AlwaysValid.php @@ -20,7 +20,7 @@ )] final class AlwaysValid extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return true; } diff --git a/library/Rules/ArrayType.php b/library/Rules/ArrayType.php index eff84f9d8..6906c94ef 100644 --- a/library/Rules/ArrayType.php +++ b/library/Rules/ArrayType.php @@ -22,7 +22,7 @@ )] final class ArrayType extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_array($input); } diff --git a/library/Rules/ArrayVal.php b/library/Rules/ArrayVal.php index 7d2e32686..3368faa10 100644 --- a/library/Rules/ArrayVal.php +++ b/library/Rules/ArrayVal.php @@ -24,7 +24,7 @@ )] final class ArrayVal extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_array($input) || $input instanceof ArrayAccess || $input instanceof SimpleXMLElement; } diff --git a/library/Rules/Base64.php b/library/Rules/Base64.php index ced23218c..6996f1229 100644 --- a/library/Rules/Base64.php +++ b/library/Rules/Base64.php @@ -24,7 +24,7 @@ )] final class Base64 extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input)) { return false; diff --git a/library/Rules/BoolType.php b/library/Rules/BoolType.php index 45049b31e..b27cae6ee 100644 --- a/library/Rules/BoolType.php +++ b/library/Rules/BoolType.php @@ -22,7 +22,7 @@ )] final class BoolType extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_bool($input); } diff --git a/library/Rules/BoolVal.php b/library/Rules/BoolVal.php index ee765fec6..bd4c53924 100644 --- a/library/Rules/BoolVal.php +++ b/library/Rules/BoolVal.php @@ -26,7 +26,7 @@ )] final class BoolVal extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_bool(filter_var($input, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)); } diff --git a/library/Rules/Bsn.php b/library/Rules/Bsn.php index f29c71134..cc5d1d9db 100644 --- a/library/Rules/Bsn.php +++ b/library/Rules/Bsn.php @@ -29,7 +29,7 @@ )] final class Bsn extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_scalar($input)) { return false; diff --git a/library/Rules/CallableType.php b/library/Rules/CallableType.php index 253c0993d..66985570a 100644 --- a/library/Rules/CallableType.php +++ b/library/Rules/CallableType.php @@ -22,7 +22,7 @@ )] final class CallableType extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_callable($input); } diff --git a/library/Rules/Callback.php b/library/Rules/Callback.php index 87e12c5c3..2847f81d0 100644 --- a/library/Rules/Callback.php +++ b/library/Rules/Callback.php @@ -40,7 +40,7 @@ public function __construct(callable $callback, mixed ...$arguments) $this->arguments = $arguments; } - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return (bool) call_user_func_array($this->callback, $this->getArguments($input)); } diff --git a/library/Rules/Cnh.php b/library/Rules/Cnh.php index c82dd78d4..5934f7bbe 100644 --- a/library/Rules/Cnh.php +++ b/library/Rules/Cnh.php @@ -24,7 +24,7 @@ )] final class Cnh extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_scalar($input)) { return false; diff --git a/library/Rules/Cnpj.php b/library/Rules/Cnpj.php index 08937e8c3..be4b2e338 100644 --- a/library/Rules/Cnpj.php +++ b/library/Rules/Cnpj.php @@ -27,7 +27,7 @@ )] final class Cnpj extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_scalar($input)) { return false; diff --git a/library/Rules/Core/Simple.php b/library/Rules/Core/Simple.php index 7e42c14eb..bb4fcac23 100644 --- a/library/Rules/Core/Simple.php +++ b/library/Rules/Core/Simple.php @@ -13,7 +13,7 @@ abstract class Simple extends Standard { - abstract protected function isValid(mixed $input): bool; + abstract public function isValid(mixed $input): bool; public function evaluate(mixed $input): Result { diff --git a/library/Rules/Countable.php b/library/Rules/Countable.php index caa08e1ab..68802d6d5 100644 --- a/library/Rules/Countable.php +++ b/library/Rules/Countable.php @@ -23,7 +23,7 @@ )] final class Countable extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_array($input) || $input instanceof CountableInterface; } diff --git a/library/Rules/Cpf.php b/library/Rules/Cpf.php index 41694ca05..b02329c77 100644 --- a/library/Rules/Cpf.php +++ b/library/Rules/Cpf.php @@ -25,7 +25,7 @@ )] final class Cpf extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { // Code ported from jsfromhell.com $c = preg_replace('/\D/', '', $input); diff --git a/library/Rules/Directory.php b/library/Rules/Directory.php index 036f305b1..9ea7fa53b 100644 --- a/library/Rules/Directory.php +++ b/library/Rules/Directory.php @@ -25,7 +25,7 @@ )] final class Directory extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if ($input instanceof SplFileInfo) { return $input->isDir(); diff --git a/library/Rules/Email.php b/library/Rules/Email.php index 34e44a787..e8971bd00 100644 --- a/library/Rules/Email.php +++ b/library/Rules/Email.php @@ -39,7 +39,7 @@ public function __construct(?EmailValidator $validator = null) $this->validator = $validator; } - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input)) { return false; diff --git a/library/Rules/Even.php b/library/Rules/Even.php index 3e67c319b..4600e6aec 100644 --- a/library/Rules/Even.php +++ b/library/Rules/Even.php @@ -24,7 +24,7 @@ )] final class Even extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (filter_var($input, FILTER_VALIDATE_INT) === false) { return false; diff --git a/library/Rules/Executable.php b/library/Rules/Executable.php index 93bea4644..100045e85 100644 --- a/library/Rules/Executable.php +++ b/library/Rules/Executable.php @@ -24,7 +24,7 @@ )] final class Executable extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if ($input instanceof SplFileInfo) { return $input->isExecutable(); diff --git a/library/Rules/Exists.php b/library/Rules/Exists.php index 4bef376a8..5fefc3e3b 100644 --- a/library/Rules/Exists.php +++ b/library/Rules/Exists.php @@ -24,7 +24,7 @@ )] final class Exists extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if ($input instanceof SplFileInfo) { $input = $input->getPathname(); diff --git a/library/Rules/FalseVal.php b/library/Rules/FalseVal.php index 1cc65cac7..495d37889 100644 --- a/library/Rules/FalseVal.php +++ b/library/Rules/FalseVal.php @@ -25,7 +25,7 @@ )] final class FalseVal extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return filter_var($input, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) === false; } diff --git a/library/Rules/Fibonacci.php b/library/Rules/Fibonacci.php index 705a72f7a..da22acbe8 100644 --- a/library/Rules/Fibonacci.php +++ b/library/Rules/Fibonacci.php @@ -22,7 +22,7 @@ )] final class Fibonacci extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_numeric($input)) { return false; diff --git a/library/Rules/File.php b/library/Rules/File.php index b6f892467..27743d02f 100644 --- a/library/Rules/File.php +++ b/library/Rules/File.php @@ -24,7 +24,7 @@ )] final class File extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if ($input instanceof SplFileInfo) { return $input->isFile(); diff --git a/library/Rules/Finite.php b/library/Rules/Finite.php index 20c1fa04f..9e3a69414 100644 --- a/library/Rules/Finite.php +++ b/library/Rules/Finite.php @@ -23,7 +23,7 @@ )] final class Finite extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_numeric($input) && is_finite((float) $input); } diff --git a/library/Rules/FloatType.php b/library/Rules/FloatType.php index 2ad8ffd17..ed4b89309 100644 --- a/library/Rules/FloatType.php +++ b/library/Rules/FloatType.php @@ -22,7 +22,7 @@ )] final class FloatType extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_float($input); } diff --git a/library/Rules/FloatVal.php b/library/Rules/FloatVal.php index dd9aa907d..9369dab63 100644 --- a/library/Rules/FloatVal.php +++ b/library/Rules/FloatVal.php @@ -25,7 +25,7 @@ )] final class FloatVal extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_float(filter_var($input, FILTER_VALIDATE_FLOAT)); } diff --git a/library/Rules/Hetu.php b/library/Rules/Hetu.php index 08211a8af..c7452a5d8 100644 --- a/library/Rules/Hetu.php +++ b/library/Rules/Hetu.php @@ -30,7 +30,7 @@ final class Hetu extends Simple { use CanValidateDateTime; - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input)) { return false; diff --git a/library/Rules/Iban.php b/library/Rules/Iban.php index 9bb9a749c..b515b0ffd 100644 --- a/library/Rules/Iban.php +++ b/library/Rules/Iban.php @@ -105,7 +105,7 @@ final class Iban extends Simple 'VG' => 24, ]; - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input)) { return false; diff --git a/library/Rules/Image.php b/library/Rules/Image.php index 27a12320e..d4daf7b3a 100644 --- a/library/Rules/Image.php +++ b/library/Rules/Image.php @@ -35,7 +35,7 @@ public function __construct(?finfo $fileInfo = null) $this->fileInfo = $fileInfo ?: new finfo(FILEINFO_MIME_TYPE); } - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if ($input instanceof SplFileInfo) { return $this->isValid($input->getPathname()); diff --git a/library/Rules/Imei.php b/library/Rules/Imei.php index 16d83302d..5e727ce32 100644 --- a/library/Rules/Imei.php +++ b/library/Rules/Imei.php @@ -26,7 +26,7 @@ final class Imei extends Simple { private const IMEI_SIZE = 15; - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_scalar($input)) { return false; diff --git a/library/Rules/Infinite.php b/library/Rules/Infinite.php index f5a7b56f0..c0beff501 100644 --- a/library/Rules/Infinite.php +++ b/library/Rules/Infinite.php @@ -23,7 +23,7 @@ )] final class Infinite extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_numeric($input) && is_infinite((float) $input); } diff --git a/library/Rules/IntType.php b/library/Rules/IntType.php index 154d610c1..7ba0e22ca 100644 --- a/library/Rules/IntType.php +++ b/library/Rules/IntType.php @@ -22,7 +22,7 @@ )] final class IntType extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_int($input); } diff --git a/library/Rules/IntVal.php b/library/Rules/IntVal.php index d2f5d83fd..dc31fa86c 100644 --- a/library/Rules/IntVal.php +++ b/library/Rules/IntVal.php @@ -24,7 +24,7 @@ )] final class IntVal extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (is_int($input)) { return true; diff --git a/library/Rules/Isbn.php b/library/Rules/Isbn.php index 494087df7..6215b8935 100644 --- a/library/Rules/Isbn.php +++ b/library/Rules/Isbn.php @@ -34,7 +34,7 @@ final class Isbn extends Simple '(?:97[89][- ]?)?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X]$', ]; - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_scalar($input)) { return false; diff --git a/library/Rules/IterableType.php b/library/Rules/IterableType.php index 58b4285e9..9cad69e53 100644 --- a/library/Rules/IterableType.php +++ b/library/Rules/IterableType.php @@ -22,7 +22,7 @@ )] final class IterableType extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_iterable($input); } diff --git a/library/Rules/IterableVal.php b/library/Rules/IterableVal.php index f0ab3feae..eddf22869 100644 --- a/library/Rules/IterableVal.php +++ b/library/Rules/IterableVal.php @@ -23,7 +23,7 @@ final class IterableVal extends Simple { use CanValidateIterable; - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return $this->isIterable($input); } diff --git a/library/Rules/Json.php b/library/Rules/Json.php index d68424486..afc100035 100644 --- a/library/Rules/Json.php +++ b/library/Rules/Json.php @@ -28,7 +28,7 @@ )] final class Json extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input) || $input === '') { return false; diff --git a/library/Rules/LeapDate.php b/library/Rules/LeapDate.php index ffd435b9e..826f6195c 100644 --- a/library/Rules/LeapDate.php +++ b/library/Rules/LeapDate.php @@ -29,7 +29,7 @@ public function __construct( ) { } - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if ($input instanceof DateTimeInterface) { return $input->format('m-d') === '02-29'; diff --git a/library/Rules/LeapYear.php b/library/Rules/LeapYear.php index 73cc65695..a6a8e75e2 100644 --- a/library/Rules/LeapYear.php +++ b/library/Rules/LeapYear.php @@ -27,7 +27,7 @@ )] final class LeapYear extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (is_numeric($input)) { $date = strtotime(sprintf('%d-02-29', (int) $input)); diff --git a/library/Rules/Lowercase.php b/library/Rules/Lowercase.php index 29de040ee..a4acf2fba 100644 --- a/library/Rules/Lowercase.php +++ b/library/Rules/Lowercase.php @@ -23,7 +23,7 @@ )] final class Lowercase extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input)) { return false; diff --git a/library/Rules/Luhn.php b/library/Rules/Luhn.php index 70ccf3083..abd0e17b8 100644 --- a/library/Rules/Luhn.php +++ b/library/Rules/Luhn.php @@ -27,7 +27,7 @@ )] final class Luhn extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!(new Digit())->evaluate($input)->isValid) { return false; diff --git a/library/Rules/MacAddress.php b/library/Rules/MacAddress.php index 9a954c9c1..b46c41811 100644 --- a/library/Rules/MacAddress.php +++ b/library/Rules/MacAddress.php @@ -23,7 +23,7 @@ )] final class MacAddress extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input)) { return false; diff --git a/library/Rules/Negative.php b/library/Rules/Negative.php index fb2183e4b..60a3074ab 100644 --- a/library/Rules/Negative.php +++ b/library/Rules/Negative.php @@ -22,7 +22,7 @@ )] final class Negative extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_numeric($input)) { return false; diff --git a/library/Rules/NfeAccessKey.php b/library/Rules/NfeAccessKey.php index f991dbdd7..125523bd9 100644 --- a/library/Rules/NfeAccessKey.php +++ b/library/Rules/NfeAccessKey.php @@ -28,7 +28,7 @@ )] final class NfeAccessKey extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (mb_strlen($input) !== 44) { return false; diff --git a/library/Rules/Nif.php b/library/Rules/Nif.php index ce58e8c5c..0720b1101 100644 --- a/library/Rules/Nif.php +++ b/library/Rules/Nif.php @@ -31,7 +31,7 @@ )] final class Nif extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input)) { return false; diff --git a/library/Rules/Nip.php b/library/Rules/Nip.php index f75da0bc0..aaf7c85fe 100644 --- a/library/Rules/Nip.php +++ b/library/Rules/Nip.php @@ -28,7 +28,7 @@ )] final class Nip extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_scalar($input)) { return false; diff --git a/library/Rules/NoWhitespace.php b/library/Rules/NoWhitespace.php index fb4d7de26..264a39381 100644 --- a/library/Rules/NoWhitespace.php +++ b/library/Rules/NoWhitespace.php @@ -24,7 +24,7 @@ )] final class NoWhitespace extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (is_null($input)) { return true; diff --git a/library/Rules/NotEmoji.php b/library/Rules/NotEmoji.php index 9e3d6d70f..0834cbb5a 100644 --- a/library/Rules/NotEmoji.php +++ b/library/Rules/NotEmoji.php @@ -196,7 +196,7 @@ final class NotEmoji extends Simple '\x{3299}', ]; - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input)) { return false; diff --git a/library/Rules/NullType.php b/library/Rules/NullType.php index ad5322d71..e6d2bf802 100644 --- a/library/Rules/NullType.php +++ b/library/Rules/NullType.php @@ -22,7 +22,7 @@ )] final class NullType extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_null($input); } diff --git a/library/Rules/Number.php b/library/Rules/Number.php index 816697f0c..ebe4151c6 100644 --- a/library/Rules/Number.php +++ b/library/Rules/Number.php @@ -23,7 +23,7 @@ )] final class Number extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_numeric($input)) { return false; diff --git a/library/Rules/NumericVal.php b/library/Rules/NumericVal.php index 223b8dee6..74958a08d 100644 --- a/library/Rules/NumericVal.php +++ b/library/Rules/NumericVal.php @@ -22,7 +22,7 @@ )] final class NumericVal extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_numeric($input); } diff --git a/library/Rules/ObjectType.php b/library/Rules/ObjectType.php index 9dd4ba9e9..b94d8c605 100644 --- a/library/Rules/ObjectType.php +++ b/library/Rules/ObjectType.php @@ -22,7 +22,7 @@ )] final class ObjectType extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_object($input); } diff --git a/library/Rules/Odd.php b/library/Rules/Odd.php index 2842a57d3..3dda2c03e 100644 --- a/library/Rules/Odd.php +++ b/library/Rules/Odd.php @@ -25,7 +25,7 @@ )] final class Odd extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_numeric($input)) { return false; diff --git a/library/Rules/PerfectSquare.php b/library/Rules/PerfectSquare.php index 53b806661..369b37ee7 100644 --- a/library/Rules/PerfectSquare.php +++ b/library/Rules/PerfectSquare.php @@ -24,7 +24,7 @@ )] final class PerfectSquare extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_numeric($input) && floor(sqrt((float) $input)) == sqrt((float) $input); } diff --git a/library/Rules/Pesel.php b/library/Rules/Pesel.php index 6095ff8ba..e633f89f8 100644 --- a/library/Rules/Pesel.php +++ b/library/Rules/Pesel.php @@ -23,7 +23,7 @@ )] final class Pesel extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_scalar($input)) { return false; diff --git a/library/Rules/PhpLabel.php b/library/Rules/PhpLabel.php index 21298dd13..6d7f6e8b7 100644 --- a/library/Rules/PhpLabel.php +++ b/library/Rules/PhpLabel.php @@ -23,7 +23,7 @@ )] final class PhpLabel extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_string($input) && preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $input); } diff --git a/library/Rules/Pis.php b/library/Rules/Pis.php index b9ccd78fd..8f32b68e6 100644 --- a/library/Rules/Pis.php +++ b/library/Rules/Pis.php @@ -25,7 +25,7 @@ )] final class Pis extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_scalar($input)) { return false; diff --git a/library/Rules/PolishIdCard.php b/library/Rules/PolishIdCard.php index 791f020a0..511d7dbf2 100644 --- a/library/Rules/PolishIdCard.php +++ b/library/Rules/PolishIdCard.php @@ -32,7 +32,7 @@ final class PolishIdCard extends Simple private const ASCII_CODE_9 = 57; private const ASCII_CODE_A = 65; - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_scalar($input)) { return false; diff --git a/library/Rules/PortugueseNif.php b/library/Rules/PortugueseNif.php index 5df64abb2..b3d8dd1ae 100644 --- a/library/Rules/PortugueseNif.php +++ b/library/Rules/PortugueseNif.php @@ -33,7 +33,7 @@ )] final class PortugueseNif extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { // Validate format and length if (!is_string($input)) { diff --git a/library/Rules/Positive.php b/library/Rules/Positive.php index 626b47039..d16d7dd86 100644 --- a/library/Rules/Positive.php +++ b/library/Rules/Positive.php @@ -22,7 +22,7 @@ )] final class Positive extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_numeric($input)) { return false; diff --git a/library/Rules/PrimeNumber.php b/library/Rules/PrimeNumber.php index 7edb0269e..4b83feefa 100644 --- a/library/Rules/PrimeNumber.php +++ b/library/Rules/PrimeNumber.php @@ -24,7 +24,7 @@ )] final class PrimeNumber extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_numeric($input) || $input <= 1) { return false; diff --git a/library/Rules/PublicDomainSuffix.php b/library/Rules/PublicDomainSuffix.php index c46a503bd..4a24873c7 100644 --- a/library/Rules/PublicDomainSuffix.php +++ b/library/Rules/PublicDomainSuffix.php @@ -30,7 +30,7 @@ final class PublicDomainSuffix extends Simple { use CanValidateUndefined; - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_scalar($input)) { return false; diff --git a/library/Rules/Readable.php b/library/Rules/Readable.php index 5cdb25b20..a6b60f671 100644 --- a/library/Rules/Readable.php +++ b/library/Rules/Readable.php @@ -25,7 +25,7 @@ )] final class Readable extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if ($input instanceof SplFileInfo) { return $input->isReadable(); diff --git a/library/Rules/ResourceType.php b/library/Rules/ResourceType.php index 2b545e187..acc890fe9 100644 --- a/library/Rules/ResourceType.php +++ b/library/Rules/ResourceType.php @@ -22,7 +22,7 @@ )] final class ResourceType extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_resource($input); } diff --git a/library/Rules/ScalarVal.php b/library/Rules/ScalarVal.php index 50524404b..e31704310 100644 --- a/library/Rules/ScalarVal.php +++ b/library/Rules/ScalarVal.php @@ -22,7 +22,7 @@ )] final class ScalarVal extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_scalar($input); } diff --git a/library/Rules/Slug.php b/library/Rules/Slug.php index c47f618d5..aecad1b8b 100644 --- a/library/Rules/Slug.php +++ b/library/Rules/Slug.php @@ -24,7 +24,7 @@ )] final class Slug extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input) || mb_strstr($input, '--')) { return false; diff --git a/library/Rules/StringType.php b/library/Rules/StringType.php index de112cdad..de0e500eb 100644 --- a/library/Rules/StringType.php +++ b/library/Rules/StringType.php @@ -22,7 +22,7 @@ )] final class StringType extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_string($input); } diff --git a/library/Rules/StringVal.php b/library/Rules/StringVal.php index 6058987e7..62ef02c0a 100644 --- a/library/Rules/StringVal.php +++ b/library/Rules/StringVal.php @@ -24,7 +24,7 @@ )] final class StringVal extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return is_scalar($input) || (is_object($input) && method_exists($input, '__toString')); } diff --git a/library/Rules/SymbolicLink.php b/library/Rules/SymbolicLink.php index 59f2a7500..58b654435 100644 --- a/library/Rules/SymbolicLink.php +++ b/library/Rules/SymbolicLink.php @@ -24,7 +24,7 @@ )] final class SymbolicLink extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if ($input instanceof SplFileInfo) { return $input->isLink(); diff --git a/library/Rules/Tld.php b/library/Rules/Tld.php index 0d7512253..43aad3c5c 100644 --- a/library/Rules/Tld.php +++ b/library/Rules/Tld.php @@ -237,7 +237,7 @@ final class Tld extends Simple 'ZA', 'ZAPPOS', 'ZARA', 'ZERO', 'ZIP', 'ZM', 'ZONE', 'ZUERICH', 'ZW', ]; - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_scalar($input)) { return false; diff --git a/library/Rules/TrueVal.php b/library/Rules/TrueVal.php index b70681070..1d9dee560 100644 --- a/library/Rules/TrueVal.php +++ b/library/Rules/TrueVal.php @@ -25,7 +25,7 @@ )] final class TrueVal extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return filter_var($input, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) === true; } diff --git a/library/Rules/Unique.php b/library/Rules/Unique.php index e3c047722..b060f54f4 100644 --- a/library/Rules/Unique.php +++ b/library/Rules/Unique.php @@ -25,7 +25,7 @@ )] final class Unique extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_array($input)) { return false; diff --git a/library/Rules/Uploaded.php b/library/Rules/Uploaded.php index ee49c98b0..4de5ac827 100644 --- a/library/Rules/Uploaded.php +++ b/library/Rules/Uploaded.php @@ -25,7 +25,7 @@ )] final class Uploaded extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if ($input instanceof SplFileInfo) { return $this->isValid($input->getPathname()); diff --git a/library/Rules/Uppercase.php b/library/Rules/Uppercase.php index 1b9c25e97..e51c6f43d 100644 --- a/library/Rules/Uppercase.php +++ b/library/Rules/Uppercase.php @@ -23,7 +23,7 @@ )] final class Uppercase extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input)) { return false; diff --git a/library/Rules/Version.php b/library/Rules/Version.php index d1750c59f..80b791ae4 100644 --- a/library/Rules/Version.php +++ b/library/Rules/Version.php @@ -26,7 +26,7 @@ )] final class Version extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input)) { return false; diff --git a/library/Rules/Writable.php b/library/Rules/Writable.php index d9a1f78e3..0f76953f9 100644 --- a/library/Rules/Writable.php +++ b/library/Rules/Writable.php @@ -25,7 +25,7 @@ )] final class Writable extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if ($input instanceof SplFileInfo) { return $input->isWritable(); diff --git a/library/Rules/Yes.php b/library/Rules/Yes.php index 75b45a135..70c967e4d 100644 --- a/library/Rules/Yes.php +++ b/library/Rules/Yes.php @@ -31,7 +31,7 @@ public function __construct( ) { } - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { if (!is_string($input)) { return false; diff --git a/tests/feature/Issues/Issue1477Test.php b/tests/feature/Issues/Issue1477Test.php index a55443f46..737e982fd 100644 --- a/tests/feature/Issues/Issue1477Test.php +++ b/tests/feature/Issues/Issue1477Test.php @@ -15,7 +15,7 @@ function (): void { 'Address', v::templated( new class extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return false; } diff --git a/tests/library/Rules/Core/ConcreteSimple.php b/tests/library/Rules/Core/ConcreteSimple.php index 4c05e538d..fbb91aebd 100644 --- a/tests/library/Rules/Core/ConcreteSimple.php +++ b/tests/library/Rules/Core/ConcreteSimple.php @@ -13,7 +13,7 @@ final class ConcreteSimple extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return true; } diff --git a/tests/library/Rules/CustomRule.php b/tests/library/Rules/CustomRule.php index 189752106..8432097d7 100644 --- a/tests/library/Rules/CustomRule.php +++ b/tests/library/Rules/CustomRule.php @@ -13,7 +13,7 @@ final class CustomRule extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return false; } diff --git a/tests/library/Rules/Stub.php b/tests/library/Rules/Stub.php index ce290f5eb..832868fc0 100644 --- a/tests/library/Rules/Stub.php +++ b/tests/library/Rules/Stub.php @@ -55,7 +55,7 @@ public static function fail(int $expectedCount): self return new self(...array_fill(0, $expectedCount, false)); } - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { $this->inputs[] = $input; diff --git a/tests/library/Rules/Valid.php b/tests/library/Rules/Valid.php index d9e041195..ed17074be 100644 --- a/tests/library/Rules/Valid.php +++ b/tests/library/Rules/Valid.php @@ -13,7 +13,7 @@ final class Valid extends Simple { - protected function isValid(mixed $input): bool + public function isValid(mixed $input): bool { return true; }