Skip to content

Commit

Permalink
Use readonly class annotation where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk committed Oct 28, 2024
1 parent 12f92de commit 266b724
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
5 changes: 2 additions & 3 deletions src/Storageless/Http/ClientFingerprint/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

namespace PSR7Sessions\Storageless\Http\ClientFingerprint;

/** @immutable */
final class Configuration
final readonly class Configuration
{
/** @var list<Source> */
private readonly array $sources;
private array $sources;

/**
* @param list<Source> ...$sources
Expand Down
3 changes: 1 addition & 2 deletions src/Storageless/Http/ClientFingerprint/RemoteAddr.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
use function array_key_exists;
use function is_string;

/** @immutable */
final class RemoteAddr implements Source
final readonly class RemoteAddr implements Source
{
private const SERVER_PARAM_NAME = 'REMOTE_ADDR';

Expand Down
14 changes: 5 additions & 9 deletions src/Storageless/Http/ClientFingerprint/SameOriginRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,18 @@

use const JSON_THROW_ON_ERROR;

/**
* @internal
*
* @immutable
*/
final class SameOriginRequest implements Constraint
/** @internal */
final readonly class SameOriginRequest implements Constraint
{
public const CLAIM = 'fp';

/** @var list<Source> */
private readonly array $sources;
private array $sources;
/** @var non-empty-string */
private readonly string $currentRequestFingerprint;
private string $currentRequestFingerprint;

public function __construct(
private readonly Configuration $configuration,
private Configuration $configuration,
ServerRequestInterface $serverRequest,
) {
$this->sources = $this->configuration->sources();
Expand Down
3 changes: 1 addition & 2 deletions src/Storageless/Http/ClientFingerprint/UserAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

use Psr\Http\Message\ServerRequestInterface;

/** @immutable */
final class UserAgent implements Source
final readonly class UserAgent implements Source
{
public function extractFrom(ServerRequestInterface $request): string
{
Expand Down
5 changes: 2 additions & 3 deletions src/Storageless/Http/SessionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@

use function sprintf;

/** @immutable */
final class SessionMiddleware implements MiddlewareInterface
final readonly class SessionMiddleware implements MiddlewareInterface
{
public const SESSION_CLAIM = 'session-data';
public const SESSION_ATTRIBUTE = 'session';

public function __construct(
private readonly Configuration $config,
private Configuration $config,
) {
}

Expand Down

0 comments on commit 266b724

Please sign in to comment.