From 3aa4f874d36e2368a57b2ad4c9ca1abe13514e66 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 4 Nov 2024 04:00:05 +0100 Subject: [PATCH] Fix deprecation warnings thrown when used with PHP 8.4 (#32) * Drop support for PHP older than 7.1 * Add PHP 8.4 to php workflow * Fix PHP 8.4 deprecation warning by making nullable all vars with null default value --- .github/workflows/php.yml | 2 +- composer.json | 2 +- src/Client.php | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index aecd1e5..35ce227 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: operating-system: ['ubuntu-latest', 'macos-latest'] - php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] phpunit-versions: ['latest'] steps: diff --git a/composer.json b/composer.json index f4f0eb1..1b1db59 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "~5.6|~7.0|~8.0", + "php": "~7.1|~8.0", "paragonie/random_compat": ">=2.0" }, "require-dev": { diff --git a/src/Client.php b/src/Client.php index cb6aea2..fb1e29e 100644 --- a/src/Client.php +++ b/src/Client.php @@ -34,9 +34,9 @@ class Client * * @codeCoverageIgnore * @param integer $size - * @param GeneratorInterface $generator + * @param GeneratorInterface|null $generator */ - public function __construct($size = 21, GeneratorInterface $generator = null) + public function __construct($size = 21, ?GeneratorInterface $generator = null) { $this->size = $size > 0 ? $size : 21; $this->generator = $generator ?: new Generator(); @@ -67,12 +67,12 @@ public function generateId($size = 0, $mode = self::MODE_NORMAL) * you have been implements your custom GeneratorInterface as correctly. * Otherwise use the build-in default random bytes generator * - * @param GeneratorInterface $generator + * @param GeneratorInterface|null $generator * @param integer $size * @param string $alphabet default CoreInterface::SAFE_SYMBOLS * @return string */ - public function formattedId($alphabet, $size = 0, GeneratorInterface $generator = null) + public function formattedId($alphabet, $size = 0, ?GeneratorInterface $generator = null) { $alphabet = $alphabet ?: CoreInterface::SAFE_SYMBOLS; $size = $size > 0 ? $size : $this->size; @@ -86,12 +86,12 @@ public function formattedId($alphabet, $size = 0, GeneratorInterface $generator * * @param string $alphabet * @param integer $size - * @param GeneratorInterface $generator + * @param GeneratorInterface|null $generator * * @return string * @since 1.0.0 */ - public function formatedId($alphabet, $size = 0, GeneratorInterface $generator = null) + public function formatedId($alphabet, $size = 0, ?GeneratorInterface $generator = null) { $size = $size > 0 ? $size : $this->size;