From df252f6b18fd43c1599b07266ac70046f6afbc1d Mon Sep 17 00:00:00 2001 From: Italo Israel Baeza Cabrera Date: Wed, 29 Jan 2025 15:14:25 -0300 Subject: [PATCH] PHP 8.4 support --- .gitattributes | 1 + .github/workflows/php.yml | 1 + phpstan.neon | 3 +++ src/Exceptions/EmptyRutException.php | 2 +- src/Exceptions/InvalidRutException.php | 2 +- src/Rules/RutUnique.php | 2 +- src/Rut.php | 4 ++-- 7 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 phpstan.neon diff --git a/.gitattributes b/.gitattributes index 283a98b..25f2cb6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,3 +11,4 @@ /.editorconfig export-ignore /composer.lock export-ignore /.styleci.yml export-ignore +/phpstan.neon export-ignore diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 7d9e607..7445116 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -53,6 +53,7 @@ jobs: - 8.1 - 8.2 - 8.3 + - 8.4 laravel-constraint: - 10.* - 11.* diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..7e13e2a --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,3 @@ +parameters: + ignoreErrors: + - '#Trait Laragear\\Rut\\HasRut is used zero times and is not analysed\.#' diff --git a/src/Exceptions/EmptyRutException.php b/src/Exceptions/EmptyRutException.php index 59b9876..efd446d 100644 --- a/src/Exceptions/EmptyRutException.php +++ b/src/Exceptions/EmptyRutException.php @@ -13,7 +13,7 @@ class EmptyRutException extends LogicException implements RutException public function __construct( string $message = 'The RUT needs at least 7 valid characters.', int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ) { parent::__construct($message, $code, $previous); } diff --git a/src/Exceptions/InvalidRutException.php b/src/Exceptions/InvalidRutException.php index 4b291da..149cae9 100644 --- a/src/Exceptions/InvalidRutException.php +++ b/src/Exceptions/InvalidRutException.php @@ -13,7 +13,7 @@ class InvalidRutException extends LogicException implements RutException public function __construct( string $message = 'The given RUT is invalid.', int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ) { parent::__construct($message, $code, $previous); } diff --git a/src/Rules/RutUnique.php b/src/Rules/RutUnique.php index 0e4dd32..d9e389f 100644 --- a/src/Rules/RutUnique.php +++ b/src/Rules/RutUnique.php @@ -33,7 +33,7 @@ public function __construct( * * @return $this */ - public function ignore(mixed $id, string $idColumn = null): RutUnique + public function ignore(mixed $id, ?string $idColumn = null): RutUnique { if ($id instanceof Model) { return $this->ignoreModel($id, $idColumn); diff --git a/src/Rut.php b/src/Rut.php index 2541aad..b04102e 100644 --- a/src/Rut.php +++ b/src/Rut.php @@ -196,7 +196,7 @@ public function isNotEqual(self|int|string $rut): bool /** * Formats the RUT to a string using the default style or the given style. */ - public function format(RutFormat $format = null): string + public function format(?RutFormat $format = null): string { $format ??= static::$format; @@ -296,7 +296,7 @@ public static function map(iterable $ruts): Collection * @param int|string|null $vd * @return bool */ - public static function check(int|string $num, int|string $vd = null): bool + public static function check(int|string $num, int|string|null $vd = null): bool { // If the developer only issued the num, we will understand is the whole RUT. if (null === $vd) {