From d4a2729b0d56db95f8880e5e37e00fb16ed4c5ac Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 22 Mar 2026 13:17:54 +0000 Subject: [PATCH] Raise supported PHP version to 8.0 and related updates --- .github/workflows/php.yml | 3 --- composer.json | 8 ++++---- phpunit.xml | 25 ++++++++++++------------- src/HOTP.php | 4 ++-- src/HOTPResult.php | 9 +++------ 5 files changed, 21 insertions(+), 28 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index c355584..b232a6b 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -11,9 +11,6 @@ jobs: strategy: matrix: php-versions: - - "7.2" - - "7.3" - - "7.4" - "8.0" - "8.1" - "8.2" diff --git a/composer.json b/composer.json index 02d02f4..b80badd 100644 --- a/composer.json +++ b/composer.json @@ -25,14 +25,14 @@ } }, "require": { - "php": ">=7.2" + "php": ">=8.0" }, "require-dev": { - "ockcyp/covers-validator": "^1.3.3", - "phpunit/phpunit": "^8.5.13||^9.5.0", + "ockcyp/covers-validator": "^1.7.0", + "phpunit/phpunit": "^9.6.34", "php-parallel-lint/php-console-highlighter": "^1.0", "php-parallel-lint/php-parallel-lint": "^1.4", - "friendsofphp/php-cs-fixer": "^3.4", + "friendsofphp/php-cs-fixer": "^3.94", "brainmaestro/composer-git-hooks": "^2.8" }, "scripts": { diff --git a/phpunit.xml b/phpunit.xml index 94d689f..40a09ab 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,14 +1,13 @@ - - - - ./tests - - - - - ./src - - + + + + + ./src + + + + + ./tests + + diff --git a/src/HOTP.php b/src/HOTP.php index f9191c9..b461c15 100644 --- a/src/HOTP.php +++ b/src/HOTP.php @@ -46,7 +46,7 @@ public static function generateByCounter(string $key, int $counter): HOTPResult * @param int|false $timestamp a timestamp to calculate for, defaults to time() * @return HOTPResult a HOTP Result which can be truncated or output */ - public static function generateByTime(string $key, int $window, $timestamp = false): HOTPResult + public static function generateByTime(string $key, int $window, int|false $timestamp = false): HOTPResult { if (!$timestamp && $timestamp !== 0) { // @codeCoverageIgnoreStart @@ -70,7 +70,7 @@ public static function generateByTime(string $key, int $window, $timestamp = fal * @param int|false $timestamp a timestamp to calculate for, defaults to time() * @return HOTPResult[] */ - public static function generateByTimeWindow(string $key, int $window, int $min = -1, int $max = 1, $timestamp = false): array + public static function generateByTimeWindow(string $key, int $window, int $min = -1, int $max = 1, int|false $timestamp = false): array { if (!$timestamp && $timestamp !== 0) { // @codeCoverageIgnoreStart diff --git a/src/HOTPResult.php b/src/HOTPResult.php index d4a3f1d..b9e39af 100644 --- a/src/HOTPResult.php +++ b/src/HOTPResult.php @@ -14,14 +14,11 @@ */ class HOTPResult { - protected $hash; - protected $decimal; - protected $hex; + private ?int $decimal = null; + private ?string $hex = null; - public function __construct(string $value) + public function __construct(private string $hash) { - // store raw - $this->hash = $value; } /**