Skip to content

Commit

Permalink
Mark classes as readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk committed Jan 29, 2025
1 parent c62bb83 commit 55638e5
Show file tree
Hide file tree
Showing 47 changed files with 150 additions and 214 deletions.
39 changes: 6 additions & 33 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Serves like a small DI container to simplify the creation and usage
* of the objects.
*/
final class Configuration
final readonly class Configuration

Check failure on line 18 in src/Configuration.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Method Lcobucci\JWT\Configuration#setBuilderFactory() was removed

Check failure on line 18 in src/Configuration.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Method Lcobucci\JWT\Configuration#setParser() was removed

Check failure on line 18 in src/Configuration.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Method Lcobucci\JWT\Configuration#setValidator() was removed

Check failure on line 18 in src/Configuration.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Method Lcobucci\JWT\Configuration#setValidationConstraints() was removed
{
private Parser $parser;
private Validator $validator;
Expand All @@ -28,11 +28,11 @@ final class Configuration

/** @param Closure(ClaimsFormatter $claimFormatter): Builder|null $builderFactory */
private function __construct(
private readonly Signer $signer,
private readonly Key $signingKey,
private readonly Key $verificationKey,
private readonly Encoder $encoder,
private readonly Decoder $decoder,
private Signer $signer,
private Key $signingKey,
private Key $verificationKey,
private Encoder $encoder,
private Decoder $decoder,
?Parser $parser,
?Validator $validator,
?Closure $builderFactory,
Expand Down Expand Up @@ -86,15 +86,6 @@ public static function forSymmetricSigner(
);
}

Check failure on line 87 in src/Configuration.php

View workflow job for this annotation

GitHub Actions / Check Coding Standards (locked, 8.2, ubuntu-latest)

Expected 1 blank line after function; 2 found

/**
* @deprecated Deprecated since v5.5, please use {@see self::withBuilderFactory()} instead
*
* @param callable(ClaimsFormatter): Builder $builderFactory
*/
public function setBuilderFactory(callable $builderFactory): void
{
$this->builderFactory = $builderFactory(...);
}

/** @param callable(ClaimsFormatter): Builder $builderFactory */
public function withBuilderFactory(callable $builderFactory): self
Expand Down Expand Up @@ -122,12 +113,6 @@ public function parser(): Parser
return $this->parser;
}

/** @deprecated Deprecated since v5.5, please use {@see self::withParser()} instead */
public function setParser(Parser $parser): void
{
$this->parser = $parser;
}

public function withParser(Parser $parser): self
{
return new self(
Expand Down Expand Up @@ -163,12 +148,6 @@ public function validator(): Validator
return $this->validator;
}

/** @deprecated Deprecated since v5.5, please use {@see self::withValidator()} instead */
public function setValidator(Validator $validator): void
{
$this->validator = $validator;
}

public function withValidator(Validator $validator): self
{
return new self(
Expand All @@ -190,12 +169,6 @@ public function validationConstraints(): array
return $this->validationConstraints;
}

/** @deprecated Deprecated since v5.5, please use {@see self::withValidationConstraints()} instead */
public function setValidationConstraints(Constraint ...$validationConstraints): void
{
$this->validationConstraints = $validationConstraints;
}

public function withValidationConstraints(Constraint ...$validationConstraints): self
{
return new self(
Expand Down
2 changes: 1 addition & 1 deletion src/Encoding/ChainedFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Lcobucci\JWT\ClaimsFormatter;

final class ChainedFormatter implements ClaimsFormatter
final readonly class ChainedFormatter implements ClaimsFormatter
{
/** @var array<ClaimsFormatter> */
private array $formatters;
Expand Down
2 changes: 1 addition & 1 deletion src/Encoding/JoseEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* A utilitarian class that encodes and decodes data according to JOSE specifications
*/
final class JoseEncoder implements Encoder, Decoder
final readonly class JoseEncoder implements Encoder, Decoder
{
public function jsonEncode(mixed $data): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Encoding/MicrosecondBasedDateConversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use function array_key_exists;

final class MicrosecondBasedDateConversion implements ClaimsFormatter
final readonly class MicrosecondBasedDateConversion implements ClaimsFormatter
{
/** @inheritdoc */
public function formatClaims(array $claims): array
Expand Down
2 changes: 1 addition & 1 deletion src/Encoding/UnifyAudience.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function count;
use function current;

final class UnifyAudience implements ClaimsFormatter
final readonly class UnifyAudience implements ClaimsFormatter
{
/** @inheritdoc */
public function formatClaims(array $claims): array
Expand Down
2 changes: 1 addition & 1 deletion src/Encoding/UnixTimestampDates.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use function array_key_exists;

final class UnixTimestampDates implements ClaimsFormatter
final readonly class UnixTimestampDates implements ClaimsFormatter
{
/** @inheritdoc */
public function formatClaims(array $claims): array
Expand Down
6 changes: 3 additions & 3 deletions src/JwtFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

use function assert;

final class JwtFacade
final readonly class JwtFacade
{
private readonly Clock $clock;
private Clock $clock;

public function __construct(
private readonly Parser $parser = new Token\Parser(new JoseEncoder()),
private Parser $parser = new Token\Parser(new JoseEncoder()),
?Clock $clock = null,
) {
$this->clock = $clock ?? new class implements Clock {
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Blake2b.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use function sodium_crypto_generichash;
use function strlen;

final class Blake2b implements Signer
final readonly class Blake2b implements Signer
{
private const MINIMUM_KEY_LENGTH_IN_BITS = 256;

Expand Down
4 changes: 2 additions & 2 deletions src/Signer/Ecdsa.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

use const OPENSSL_KEYTYPE_EC;

abstract class Ecdsa extends OpenSSL
abstract readonly class Ecdsa extends OpenSSL
{
public function __construct(
private readonly SignatureConverter $converter = new MultibyteStringConverter(),
private SignatureConverter $converter = new MultibyteStringConverter(),
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Ecdsa/MultibyteStringConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* @internal
*/
final class MultibyteStringConverter implements SignatureConverter
final readonly class MultibyteStringConverter implements SignatureConverter
{
private const ASN1_SEQUENCE = '30';
private const ASN1_INTEGER = '02';
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Ecdsa/Sha256.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use const OPENSSL_ALGO_SHA256;

final class Sha256 extends Ecdsa
final readonly class Sha256 extends Ecdsa
{
public function algorithmId(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Ecdsa/Sha384.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use const OPENSSL_ALGO_SHA384;

final class Sha384 extends Ecdsa
final readonly class Sha384 extends Ecdsa
{
public function algorithmId(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Ecdsa/Sha512.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use const OPENSSL_ALGO_SHA512;

final class Sha512 extends Ecdsa
final readonly class Sha512 extends Ecdsa
{
public function algorithmId(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Eddsa.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use function sodium_crypto_sign_detached;
use function sodium_crypto_sign_verify_detached;

final class Eddsa implements Signer
final readonly class Eddsa implements Signer
{
public function algorithmId(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Hmac.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use function hash_hmac;
use function strlen;

abstract class Hmac implements Signer
abstract readonly class Hmac implements Signer
{
final public function sign(string $payload, Key $key): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Hmac/Sha256.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Lcobucci\JWT\Signer\Hmac;

final class Sha256 extends Hmac
final readonly class Sha256 extends Hmac
{
public function algorithmId(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Hmac/Sha384.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Lcobucci\JWT\Signer\Hmac;

final class Sha384 extends Hmac
final readonly class Sha384 extends Hmac
{
public function algorithmId(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Hmac/Sha512.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Lcobucci\JWT\Signer\Hmac;

final class Sha512 extends Hmac
final readonly class Sha512 extends Hmac
{
public function algorithmId(): string
{
Expand Down
6 changes: 3 additions & 3 deletions src/Signer/Key/InMemory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
use function assert;
use function is_string;

final class InMemory implements Key
final readonly class InMemory implements Key
{
/** @param non-empty-string $contents */
private function __construct(
#[SensitiveParameter]
public readonly string $contents,
public string $contents,
#[SensitiveParameter]
public readonly string $passphrase,
public string $passphrase,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Signer/OpenSSL.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use const OPENSSL_KEYTYPE_RSA;
use const PHP_EOL;

abstract class OpenSSL implements Signer
abstract readonly class OpenSSL implements Signer
{
protected const KEY_TYPE_MAP = [
OPENSSL_KEYTYPE_RSA => 'RSA',
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Rsa.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use const OPENSSL_KEYTYPE_RSA;

abstract class Rsa extends OpenSSL
abstract readonly class Rsa extends OpenSSL
{
private const MINIMUM_KEY_LENGTH = 2048;

Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Rsa/Sha256.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use const OPENSSL_ALGO_SHA256;

final class Sha256 extends Rsa
final readonly class Sha256 extends Rsa
{
public function algorithmId(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Rsa/Sha384.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use const OPENSSL_ALGO_SHA384;

final class Sha384 extends Rsa
final readonly class Sha384 extends Rsa
{
public function algorithmId(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Signer/Rsa/Sha512.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use const OPENSSL_ALGO_SHA512;

final class Sha512 extends Rsa
final readonly class Sha512 extends Rsa
{
public function algorithmId(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/SodiumBase64Polyfill.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use function strtr;

/** @internal */
final class SodiumBase64Polyfill
final readonly class SodiumBase64Polyfill
{
public const SODIUM_BASE64_VARIANT_ORIGINAL = 1;
public const SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING = 3;
Expand Down
Loading

0 comments on commit 55638e5

Please sign in to comment.