Skip to content

Add explicit nullable type where needed #561

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

Closed
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
4 changes: 2 additions & 2 deletions src/Bundle/JoseFramework/Routing/JWKSetLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public function add(string $pattern, string $name): void
/**
* {@inheritdoc}
*/
public function load(mixed $resource, string $type = null): RouteCollection
public function load(mixed $resource, ?string $type = null): RouteCollection
{
return $this->routes;
}

/**
* {@inheritdoc}
*/
public function supports(mixed $resource, string $type = null): bool
public function supports(mixed $resource, ?string $type = null): bool
{
return $type === 'jwkset';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Bundle/JoseFramework/Serializer/JWESerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public function __construct(
$this->serializerManager = $serializerManager;
}

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.');
Expand Down
4 changes: 2 additions & 2 deletions src/Bundle/JoseFramework/Serializer/JWSSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public function __construct(
$this->serializerManager = $serializerManager;
}

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.');
Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/JoseFramework/Services/JWEDecrypter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/JoseFramework/Services/JWSVerifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Console/KeyAnalyzerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class KeyAnalyzerCommand extends Command

public function __construct(
private readonly KeyAnalyzerManager $analyzerManager,
string $name = null
?string $name = null
) {
parent::__construct($name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Console/KeysetAnalyzerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Component/Encryption/JWEDecrypter.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ public function decryptUsingKey(JWE &$jwe, JWK $jwk, int $recipient, ?JWK $sende
*
* @param JWE $jwe A JWE object to decrypt
* @param JWKSet $jwkset The key set used to decrypt the input
* @param JWK $jwk The key used to decrypt the token in case of success
* @param JWK|null $jwk The key used to decrypt the token in case of success
* @param int $recipient The recipient used to decrypt the token in case of success
*/
public function decryptUsingKeySet(
JWE &$jwe,
JWKSet $jwkset,
int $recipient,
JWK &$jwk = null,
?JWK &$jwk = null,
?JWK $senderKey = null
): bool {
if ($jwkset->count() === 0) {
Expand All @@ -108,7 +108,7 @@ private function decryptRecipientKey(
JWE $jwe,
JWKSet $jwkset,
int $i,
JWK &$successJwk = null,
?JWK &$successJwk = null,
?JWK $senderKey = null
): ?string {
$recipient = $jwe->getRecipient($i);
Expand Down
6 changes: 3 additions & 3 deletions src/Component/Signature/JWSVerifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function verifyWithKey(JWS $jws, JWK $jwk, int $signature, ?string $detac
*
* @param JWS $jws A JWS object
* @param JWKSet $jwkset The signature will be verified using keys in the key set
* @param JWK $jwk The key used to verify the signature in case of success
* @param JWK|null $jwk The key used to verify the signature in case of success
* @param string|null $detachedPayload If not null, the value must be the detached payload encoded in Base64 URL safe. If the input contains a payload, throws an exception.
*
* @return bool true if the verification of the signature succeeded, else false
Expand All @@ -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.');
Expand All @@ -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);
Expand Down