From 95c93f2cb3ced9d3d92b293862887d0f81702123 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Sun, 24 Nov 2024 05:11:56 -0500 Subject: [PATCH 1/9] chore: fix phpstan --- src/JWT.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/JWT.php b/src/JWT.php index 9100bf0f..9a7448cb 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -204,7 +204,7 @@ public static function encode( ?array $head = null ): string { $header = ['typ' => 'JWT']; - if (isset($head) && \is_array($head)) { + if (isset($head)) { $header = \array_merge($header, $head); } $header['alg'] = $alg; @@ -251,8 +251,10 @@ public static function sign( return \hash_hmac($algorithm, $msg, $key, true); case 'openssl': $signature = ''; - if (!\is_resource($key) && !openssl_pkey_get_private($key)) { - throw new DomainException('OpenSSL unable to validate key'); + if (!\is_resource($key)) { + if (!openssl_pkey_get_private($key)) { + throw new DomainException('OpenSSL unable to validate key'); + } } $success = \openssl_sign($msg, $signature, $key, $algorithm); // @phpstan-ignore-line if (!$success) { @@ -387,12 +389,7 @@ public static function jsonDecode(string $input) */ public static function jsonEncode(array $input): string { - if (PHP_VERSION_ID >= 50400) { - $json = \json_encode($input, \JSON_UNESCAPED_SLASHES); - } else { - // PHP 5.3 only - $json = \json_encode($input); - } + $json = \json_encode($input, \JSON_UNESCAPED_SLASHES); if ($errno = \json_last_error()) { self::handleJsonError($errno); } elseif ($json === 'null') { From 7ff4c219a7b0f6e5017820675d154ee302bca308 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Sun, 24 Nov 2024 05:15:11 -0500 Subject: [PATCH 2/9] Update tests.yml --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 13fc947f..b6da79a0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,7 +35,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.2" + php-version: "8.3" - name: Run Script run: | composer global require friendsofphp/php-cs-fixer @@ -49,7 +49,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: '8.3' - name: Run Script run: | composer install From 90b2f60ff62fe8b6cd611a27c9a8c29bf89cf676 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Sun, 24 Nov 2024 06:01:14 -0500 Subject: [PATCH 3/9] Update JWT.php --- src/JWT.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/JWT.php b/src/JWT.php index 9a7448cb..e5135c62 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -251,10 +251,8 @@ public static function sign( return \hash_hmac($algorithm, $msg, $key, true); case 'openssl': $signature = ''; - if (!\is_resource($key)) { - if (!openssl_pkey_get_private($key)) { - throw new DomainException('OpenSSL unable to validate key'); - } + if (\is_resource($key) && !openssl_pkey_get_private($key)) { + throw new DomainException('OpenSSL unable to validate key'); } $success = \openssl_sign($msg, $signature, $key, $algorithm); // @phpstan-ignore-line if (!$success) { From e1f64ee8042c6a15dcd5895764a1f00da85f667c Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Sun, 24 Nov 2024 06:02:06 -0500 Subject: [PATCH 4/9] Update JWT.php --- src/JWT.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JWT.php b/src/JWT.php index e5135c62..dd9292a4 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -251,7 +251,7 @@ public static function sign( return \hash_hmac($algorithm, $msg, $key, true); case 'openssl': $signature = ''; - if (\is_resource($key) && !openssl_pkey_get_private($key)) { + if (!\is_resource($key) && !openssl_pkey_get_private($key)) { throw new DomainException('OpenSSL unable to validate key'); } $success = \openssl_sign($msg, $signature, $key, $algorithm); // @phpstan-ignore-line From a7adec257913b6c31342150bc476ee6fc0175abc Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Sun, 24 Nov 2024 06:07:08 -0500 Subject: [PATCH 5/9] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b6da79a0..80fd0122 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,5 +53,5 @@ jobs: - name: Run Script run: | composer install - composer global require phpstan/phpstan + composer global require phpstan/phpstan^1.12 ~/.composer/vendor/bin/phpstan analyse From 553a56b52edbe38f6b371917a174765a29fc3748 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Sun, 24 Nov 2024 06:08:28 -0500 Subject: [PATCH 6/9] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 80fd0122..c4c84e8f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,5 +53,5 @@ jobs: - name: Run Script run: | composer install - composer global require phpstan/phpstan^1.12 + composer global require phpstan/phpstan:^1.12 ~/.composer/vendor/bin/phpstan analyse From 48ba33a8038cafb0f9f823e1a21d4bbe2f35e561 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Sun, 24 Nov 2024 06:09:44 -0500 Subject: [PATCH 7/9] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c4c84e8f..d0054496 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,5 +53,5 @@ jobs: - name: Run Script run: | composer install - composer global require phpstan/phpstan:^1.12 + composer global require phpstan/phpstan:^1.11 ~/.composer/vendor/bin/phpstan analyse From d6c7f990f08d938669c7345a1f8456a574d2a3ef Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Sun, 24 Nov 2024 06:10:38 -0500 Subject: [PATCH 8/9] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d0054496..b010164b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,5 +53,5 @@ jobs: - name: Run Script run: | composer install - composer global require phpstan/phpstan:^1.11 + composer global require phpstan/phpstan:~1.11.0 ~/.composer/vendor/bin/phpstan analyse From 648339af989c56926d36c893bcf703a9c3955eb5 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Sun, 24 Nov 2024 06:16:03 -0500 Subject: [PATCH 9/9] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b010164b..94211f83 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,5 +53,5 @@ jobs: - name: Run Script run: | composer install - composer global require phpstan/phpstan:~1.11.0 + composer global require phpstan/phpstan:~1.10.0 ~/.composer/vendor/bin/phpstan analyse