From 0ddbcd133b8a17a1b89bc43adee0e638e0280f48 Mon Sep 17 00:00:00 2001 From: marvin255 Date: Tue, 1 Oct 2024 10:45:16 +0200 Subject: [PATCH 1/2] Fix --- .php-cs-fixer.dist.php | 18 +++++++++++------- README.md | 2 +- docker/php/Dockerfile | 9 ++++----- src/Decoder/Decoder.php | 4 ++-- src/Signer/Rsa.php | 2 +- src/Signer/SecretBase.php | 6 +++--- src/Token/Token.php | 2 +- src/Validator/ValidationResult.php | 2 +- src/Validator/Validator.php | 2 +- 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 7ee02f5..570b054 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,5 +1,8 @@ in(__DIR__); $rules = [ @@ -21,7 +24,7 @@ 'non_printable_character' => true, 'modernize_types_casting' => true, 'ordered_interfaces' => [ - 'order' => 'alpha', + 'order' => 'alpha', 'direction' => 'ascend', ], 'date_time_immutable' => true, @@ -29,9 +32,9 @@ 'combine_nested_dirname' => true, 'native_function_invocation' => [ 'include' => [ - '@compiler_optimized', - ], - 'scope' => 'namespaced', + '@compiler_optimized' + ], + 'scope' => 'namespaced', 'strict' => true, ], 'php_unit_construct' => true, @@ -43,6 +46,7 @@ 'strict_comparison' => true, ]; -$config = new PhpCsFixer\Config(); - -return $config->setRules($rules)->setFinder($finder); +return (new Config()) + ->setParallelConfig(ParallelConfigFactory::detect()) + ->setRules($rules) + ->setFinder($finder); \ No newline at end of file diff --git a/README.md b/README.md index 851540d..1418ba3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # JWT -[![Build Status](https://github.com/marvin255/jwt/workflows/marvin255_jwt/badge.svg)](https://github.com/marvin255/jwt/actions?query=workflow%3A%22marvin255_jwt%22) +[![Build Status](https://github.com/marvin255/jwt/workflows/marvin255_jwt/badge)](https://github.com/marvin255/jwt/actions?query=workflow%3A%22marvin255_jwt%22) Simple [JWT](https://tools.ietf.org/html/rfc7519) implementation for PHP. diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index f5ee37f..5162f90 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -1,5 +1,4 @@ -FROM php:8.1-cli-alpine - +FROM php:8.2-cli-alpine RUN set -xe && apk update && apk add --no-cache \ libzip \ @@ -12,8 +11,8 @@ RUN set -xe && apk update && apk add --no-cache \ git \ autoconf \ g++ \ - make \ - linux-headers + linux-headers \ + make RUN docker-php-ext-install zip opcache \ @@ -25,7 +24,7 @@ RUN docker-php-ext-install zip opcache \ && echo 'xdebug.mode=coverage' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=2.7.6 \ +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=2.7.8 \ && mkdir -p /.composer && chmod -Rf 777 /.composer diff --git a/src/Decoder/Decoder.php b/src/Decoder/Decoder.php index 8a72f59..6fd3b71 100644 --- a/src/Decoder/Decoder.php +++ b/src/Decoder/Decoder.php @@ -47,7 +47,7 @@ public function decodeString(string $tokenString): Jwt public function decodeHeader(string $httpHeader): Jwt { if (!preg_match('/Bearer\s(.+)/i', $httpHeader, $matches)) { - throw new JwtException(sprintf("Can't recognize jwt header in string: %s", $httpHeader)); + throw new JwtException(\sprintf("Can't recognize jwt header in string: %s", $httpHeader)); } return $this->decodeString($matches[1]); @@ -82,7 +82,7 @@ private function decodeJsonObject(string $part): array /** @var array */ $decoded = Base64::arrayDecode($part); } catch (\Throwable $e) { - throw new JwtException(sprintf("Can't decode token object: %s", $e->getMessage())); + throw new JwtException(\sprintf("Can't decode token object: %s", $e->getMessage())); } return $decoded; diff --git a/src/Signer/Rsa.php b/src/Signer/Rsa.php index 32b6d1b..67e3e99 100644 --- a/src/Signer/Rsa.php +++ b/src/Signer/Rsa.php @@ -19,7 +19,7 @@ abstract class Rsa implements JwtSigner { final public function __construct( private readonly ?Secret $public = null, - private readonly ?Secret $private = null + private readonly ?Secret $private = null, ) { } diff --git a/src/Signer/SecretBase.php b/src/Signer/SecretBase.php index 1608f1a..5ef3201 100644 --- a/src/Signer/SecretBase.php +++ b/src/Signer/SecretBase.php @@ -17,7 +17,7 @@ final class SecretBase implements Secret public function __construct( private readonly string $secret, - private readonly ?string $passPhrase = null + private readonly ?string $passPhrase = null, ) { } @@ -34,12 +34,12 @@ public function getSecret(): string $filePath = realpath(substr($this->secret, \strlen(self::FILE_PREFIX))); if ($filePath === false) { - throw new SecretFileNotFoundException(sprintf('Secret file %s not found or unreadable', $this->secret)); + throw new SecretFileNotFoundException(\sprintf('Secret file %s not found or unreadable', $this->secret)); } $secret = file_get_contents($filePath); if ($secret === '') { - throw new SecretFileNotFoundException(sprintf('Secret file %s is empty', $this->secret)); + throw new SecretFileNotFoundException(\sprintf('Secret file %s is empty', $this->secret)); } return $secret; diff --git a/src/Token/Token.php b/src/Token/Token.php index 87a694c..15fc696 100644 --- a/src/Token/Token.php +++ b/src/Token/Token.php @@ -14,7 +14,7 @@ final class Token implements Jwt public function __construct( private readonly JoseHeader $jose, private readonly ClaimSet $claims, - private readonly Signature $signature + private readonly Signature $signature, ) { } diff --git a/src/Validator/ValidationResult.php b/src/Validator/ValidationResult.php index 628e056..c64a7d5 100644 --- a/src/Validator/ValidationResult.php +++ b/src/Validator/ValidationResult.php @@ -12,7 +12,7 @@ final class ValidationResult public function __construct( private readonly bool $isValid, /** @var string[] */ - private readonly array $errors = [] + private readonly array $errors = [], ) { } diff --git a/src/Validator/Validator.php b/src/Validator/Validator.php index 7507fa9..c690ccf 100644 --- a/src/Validator/Validator.php +++ b/src/Validator/Validator.php @@ -23,7 +23,7 @@ public function __construct(iterable $defaultConstraints = []) $constraints = []; foreach ($defaultConstraints as $defaultConstraint) { if (!($defaultConstraint instanceof Constraint)) { - throw new JwtException(sprintf("Constraint item must be instance of '%s'", Constraint::class)); + throw new JwtException(\sprintf("Constraint item must be instance of '%s'", Constraint::class)); } $constraints[] = $defaultConstraint; } From 53f08bcbc580e3a13ed43024bf5d50c2f569b551 Mon Sep 17 00:00:00 2001 From: marvin255 Date: Tue, 1 Oct 2024 10:49:03 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1418ba3..851540d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # JWT -[![Build Status](https://github.com/marvin255/jwt/workflows/marvin255_jwt/badge)](https://github.com/marvin255/jwt/actions?query=workflow%3A%22marvin255_jwt%22) +[![Build Status](https://github.com/marvin255/jwt/workflows/marvin255_jwt/badge.svg)](https://github.com/marvin255/jwt/actions?query=workflow%3A%22marvin255_jwt%22) Simple [JWT](https://tools.ietf.org/html/rfc7519) implementation for PHP.