Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update libs #16

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use PhpCsFixer\Config;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

$finder = PhpCsFixer\Finder::create()->in(__DIR__);

$rules = [
Expand All @@ -21,17 +24,17 @@
'non_printable_character' => true,
'modernize_types_casting' => true,
'ordered_interfaces' => [
'order' => 'alpha',
'order' => 'alpha',
'direction' => 'ascend',
],
'date_time_immutable' => true,
'native_constant_invocation' => true,
'combine_nested_dirname' => true,
'native_function_invocation' => [
'include' => [
'@compiler_optimized',
],
'scope' => 'namespaced',
'@compiler_optimized'
],
'scope' => 'namespaced',
'strict' => true,
],
'php_unit_construct' => true,
Expand All @@ -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);
9 changes: 4 additions & 5 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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 \
Expand All @@ -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


Expand Down
4 changes: 2 additions & 2 deletions src/Decoder/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -82,7 +82,7 @@ private function decodeJsonObject(string $part): array
/** @var array<string, mixed> */
$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;
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Rsa.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Signer/SecretBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Token/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validator/ValidationResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class ValidationResult
public function __construct(
private readonly bool $isValid,
/** @var string[] */
private readonly array $errors = []
private readonly array $errors = [],
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading