From b855367a21cb323a3e927782b0c856adffea0d36 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 17 Apr 2024 17:36:46 +0200 Subject: [PATCH] Explicitly mark parameter as nullable --- src/Bundle/Routing/JWKSetLoader.php | 4 ++-- src/Bundle/Serializer/JWESerializer.php | 4 ++-- src/Bundle/Serializer/JWSSerializer.php | 4 ++-- src/Bundle/Services/JWEDecrypter.php | 2 +- src/Bundle/Services/JWSVerifier.php | 2 +- src/Library/Console/KeyAnalyzerCommand.php | 2 +- src/Library/Console/KeysetAnalyzerCommand.php | 2 +- src/Library/Encryption/JWEDecrypter.php | 4 ++-- src/Library/Signature/JWSVerifier.php | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Bundle/Routing/JWKSetLoader.php b/src/Bundle/Routing/JWKSetLoader.php index 68ee2ea19..6214a738e 100644 --- a/src/Bundle/Routing/JWKSetLoader.php +++ b/src/Bundle/Routing/JWKSetLoader.php @@ -29,12 +29,12 @@ public function add(string $pattern, string $name): void $this->routes->add(sprintf('jwkset_%s', $name), $route); } - public function load(mixed $resource, string $type = null): RouteCollection + public function load(mixed $resource, ?string $type = null): RouteCollection { return $this->routes; } - public function supports(mixed $resource, string $type = null): bool + public function supports(mixed $resource, ?string $type = null): bool { return $type === 'jwkset'; } diff --git a/src/Bundle/Serializer/JWESerializer.php b/src/Bundle/Serializer/JWESerializer.php index d5c9d7503..a0b662d7b 100644 --- a/src/Bundle/Serializer/JWESerializer.php +++ b/src/Bundle/Serializer/JWESerializer.php @@ -33,14 +33,14 @@ public function getSupportedTypes(?string $format): array ]; } - public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool + public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool { return $type === JWE::class && class_exists(JWESerializerManager::class) && $this->formatSupported($format); } - public function denormalize(mixed $data, string $type, string $format = null, array $context = []): JWE + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): JWE { if ($data instanceof JWE === false) { throw new LogicException('Expected data to be a JWE.'); diff --git a/src/Bundle/Serializer/JWSSerializer.php b/src/Bundle/Serializer/JWSSerializer.php index d6a224240..26e8c7e23 100644 --- a/src/Bundle/Serializer/JWSSerializer.php +++ b/src/Bundle/Serializer/JWSSerializer.php @@ -33,14 +33,14 @@ public function getSupportedTypes(?string $format): array ]; } - public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool + public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool { return $type === JWS::class && class_exists(JWSSerializerManager::class) && $this->formatSupported($format); } - public function denormalize(mixed $data, string $type, string $format = null, array $context = []): JWS + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): JWS { if ($data instanceof JWS === false) { throw new LogicException('Expected data to be a JWS.'); diff --git a/src/Bundle/Services/JWEDecrypter.php b/src/Bundle/Services/JWEDecrypter.php index 844654b4b..c247828e0 100644 --- a/src/Bundle/Services/JWEDecrypter.php +++ b/src/Bundle/Services/JWEDecrypter.php @@ -29,7 +29,7 @@ public function decryptUsingKeySet( JWE &$jwe, JWKSet $jwkset, int $recipient, - JWK &$jwk = null, + ?JWK &$jwk = null, ?JWK $senderKey = null ): bool { $success = parent::decryptUsingKeySet($jwe, $jwkset, $recipient, $jwk, $senderKey); diff --git a/src/Bundle/Services/JWSVerifier.php b/src/Bundle/Services/JWSVerifier.php index f5c058445..5b728d053 100644 --- a/src/Bundle/Services/JWSVerifier.php +++ b/src/Bundle/Services/JWSVerifier.php @@ -27,7 +27,7 @@ public function verifyWithKeySet( JWKSet $jwkset, int $signatureIndex, ?string $detachedPayload = null, - JWK &$jwk = null + ?JWK &$jwk = null ): bool { $success = parent::verifyWithKeySet($jws, $jwkset, $signatureIndex, $detachedPayload, $jwk); if ($success) { diff --git a/src/Library/Console/KeyAnalyzerCommand.php b/src/Library/Console/KeyAnalyzerCommand.php index 368fdfa65..0c269b7fa 100644 --- a/src/Library/Console/KeyAnalyzerCommand.php +++ b/src/Library/Console/KeyAnalyzerCommand.php @@ -26,7 +26,7 @@ final class KeyAnalyzerCommand extends Command public function __construct( private readonly KeyAnalyzerManager $analyzerManager, - string $name = null + ?string $name = null ) { parent::__construct($name); } diff --git a/src/Library/Console/KeysetAnalyzerCommand.php b/src/Library/Console/KeysetAnalyzerCommand.php index 826afa0c3..95dfd2f7a 100644 --- a/src/Library/Console/KeysetAnalyzerCommand.php +++ b/src/Library/Console/KeysetAnalyzerCommand.php @@ -29,7 +29,7 @@ final class KeysetAnalyzerCommand extends Command public function __construct( private readonly KeysetAnalyzerManager $keysetAnalyzerManager, private readonly KeyAnalyzerManager $keyAnalyzerManager, - string $name = null + ?string $name = null ) { parent::__construct($name); } diff --git a/src/Library/Encryption/JWEDecrypter.php b/src/Library/Encryption/JWEDecrypter.php index fdbe8d91b..0b17b4aab 100644 --- a/src/Library/Encryption/JWEDecrypter.php +++ b/src/Library/Encryption/JWEDecrypter.php @@ -115,7 +115,7 @@ public function decryptUsingKeySet( JWE &$jwe, JWKSet $jwkset, int $recipient, - JWK &$jwk = null, + ?JWK &$jwk = null, ?JWK $senderKey = null ): bool { if ($jwkset->count() === 0) { @@ -142,7 +142,7 @@ private function decryptRecipientKey( JWE $jwe, JWKSet $jwkset, int $i, - JWK &$successJwk = null, + ?JWK &$successJwk = null, ?JWK $senderKey = null ): ?string { $recipient = $jwe->getRecipient($i); diff --git a/src/Library/Signature/JWSVerifier.php b/src/Library/Signature/JWSVerifier.php index d750a507d..187d24d80 100644 --- a/src/Library/Signature/JWSVerifier.php +++ b/src/Library/Signature/JWSVerifier.php @@ -59,7 +59,7 @@ public function verifyWithKeySet( JWKSet $jwkset, int $signatureIndex, ?string $detachedPayload = null, - JWK &$jwk = null + ?JWK &$jwk = null ): bool { if ($jwkset->count() === 0) { throw new InvalidArgumentException('There is no key in the key set.'); @@ -78,7 +78,7 @@ private function verifySignature( JWKSet $jwkset, Signature $signature, ?string $detachedPayload = null, - JWK &$successJwk = null + ?JWK &$successJwk = null ): bool { $input = $this->getInputToVerify($jws, $signature, $detachedPayload); $algorithm = $this->getAlgorithm($signature);