Skip to content

Commit

Permalink
Convert classes to readonly and remove readonly from properties
Browse files Browse the repository at this point in the history
All classes in the metadata service have been converted to use the readonly modifier, which indicates that their state cannot be changed after initialization. Alongside this change, the redundant 'readonly' keyword was removed from all class properties, since properties in a 'readonly' class are implicitly readonly.
  • Loading branch information
Spomky committed Jul 11, 2024
1 parent dd031f1 commit 681aa74
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace Webauthn\MetadataService\Event;

final class BeforeCertificateChainValidation implements WebauthnEvent
final readonly class BeforeCertificateChainValidation implements WebauthnEvent
{
/**
* @param string[] $untrustedCertificates
*/
public function __construct(
public readonly array $untrustedCertificates,
public readonly string $trustedCertificate
public array $untrustedCertificates,
public string $trustedCertificate
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace Webauthn\MetadataService\Event;

final class CertificateChainValidationFailed implements WebauthnEvent
final readonly class CertificateChainValidationFailed implements WebauthnEvent
{
/**
* @param string[] $untrustedCertificates
*/
public function __construct(
public readonly array $untrustedCertificates,
public readonly string $trustedCertificate
public array $untrustedCertificates,
public string $trustedCertificate
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace Webauthn\MetadataService\Event;

final class CertificateChainValidationSucceeded implements WebauthnEvent
final readonly class CertificateChainValidationSucceeded implements WebauthnEvent
{
/**
* @param string[] $untrustedCertificates
*/
public function __construct(
public readonly array $untrustedCertificates,
public readonly string $trustedCertificate
public array $untrustedCertificates,
public string $trustedCertificate
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/metadata-service/src/Event/MetadataStatementFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use Webauthn\MetadataService\Statement\MetadataStatement;

final class MetadataStatementFound implements WebauthnEvent
final readonly class MetadataStatementFound implements WebauthnEvent
{
public function __construct(
public readonly MetadataStatement $metadataStatement
public MetadataStatement $metadataStatement
) {
}

Expand Down
16 changes: 8 additions & 8 deletions src/metadata-service/src/Statement/BiometricStatusReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace Webauthn\MetadataService\Statement;

class BiometricStatusReport
readonly class BiometricStatusReport
{
private function __construct(
public readonly ?int $certLevel,
public readonly ?int $modality,
public readonly ?string $effectiveDate,
public readonly ?string $certificationDescriptor,
public readonly ?string $certificateNumber,
public readonly ?string $certificationPolicyVersion,
public readonly ?string $certificationRequirementsVersion,
public ?int $certLevel,
public ?int $modality,
public ?string $effectiveDate,
public ?string $certificationDescriptor,
public ?string $certificateNumber,
public ?string $certificationPolicyVersion,
public ?string $certificationRequirementsVersion,
) {
}

Expand Down
10 changes: 5 additions & 5 deletions src/metadata-service/src/Statement/ExtensionDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

use Webauthn\MetadataService\Exception\MetadataStatementLoadingException;

class ExtensionDescriptor
readonly class ExtensionDescriptor
{
public function __construct(
public readonly string $id,
public readonly ?int $tag,
public readonly ?string $data,
public readonly bool $failIfUnknown
public string $id,
public ?int $tag,
public ?string $data,
public bool $failIfUnknown
) {
if ($tag !== null) {
$tag >= 0 || throw MetadataStatementLoadingException::create(
Expand Down
8 changes: 4 additions & 4 deletions src/metadata-service/src/Statement/RgbPaletteEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

use Webauthn\MetadataService\Exception\MetadataStatementLoadingException;

class RgbPaletteEntry
readonly class RgbPaletteEntry
{
public function __construct(
public readonly int $r,
public readonly int $g,
public readonly int $b,
public int $r,
public int $g,
public int $b,
) {
($r >= 0 && $r <= 255) || throw MetadataStatementLoadingException::create('The key "r" is invalid');
($g >= 0 && $g <= 255) || throw MetadataStatementLoadingException::create('The key "g" is invalid');
Expand Down
6 changes: 3 additions & 3 deletions src/metadata-service/src/Statement/RogueListEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Webauthn\MetadataService\Statement;

class RogueListEntry
readonly class RogueListEntry
{
public function __construct(
public readonly string $sk,
public readonly string $date
public string $sk,
public string $date
) {
}

Expand Down
18 changes: 9 additions & 9 deletions src/metadata-service/src/Statement/StatusReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
use Webauthn\MetadataService\Exception\MetadataStatementLoadingException;
use function in_array;

class StatusReport
readonly class StatusReport
{
/**
* @see AuthenticatorStatus
*/
public function __construct(
public readonly string $status,
public readonly ?string $effectiveDate,
public readonly ?string $certificate,
public readonly ?string $url,
public readonly ?string $certificationDescriptor,
public readonly ?string $certificateNumber,
public readonly ?string $certificationPolicyVersion,
public readonly ?string $certificationRequirementsVersion
public string $status,
public ?string $effectiveDate,
public ?string $certificate,
public ?string $url,
public ?string $certificationDescriptor,
public ?string $certificateNumber,
public ?string $certificationPolicyVersion,
public ?string $certificationRequirementsVersion
) {
in_array($status, AuthenticatorStatus::STATUSES, true) || throw MetadataStatementLoadingException::create(
'The value of the key "status" is not acceptable'
Expand Down
6 changes: 3 additions & 3 deletions src/metadata-service/src/Statement/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

use Webauthn\MetadataService\Exception\MetadataStatementLoadingException;

class Version
readonly class Version
{
public function __construct(
public readonly ?int $major,
public readonly ?int $minor
public ?int $major,
public ?int $minor
) {
if ($major === null && $minor === null) {
throw MetadataStatementLoadingException::create('Invalid data. Must contain at least one item');
Expand Down

0 comments on commit 681aa74

Please sign in to comment.