From 4552cb9ccf6bac8207ced5c251cd7462e59859e5 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Fri, 23 Aug 2024 17:22:20 -0300 Subject: [PATCH] Upgrade coding standard --- composer.json | 2 +- src/Box.php | 6 +++--- src/GenericHash.php | 6 +++--- src/Password.php | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 6ad07a4..f5ec843 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ }, "require-dev": { "ext-xdebug": "*", - "aplus/coding-standard": "^2.1", + "aplus/coding-standard": "^2.8", "ergebnis/composer-normalize": "^2.15", "phpmd/phpmd": "^2.13", "phpstan/phpstan": "^1.9", diff --git a/src/Box.php b/src/Box.php index 57bb1fd..80f79e4 100644 --- a/src/Box.php +++ b/src/Box.php @@ -46,7 +46,7 @@ public function __construct( #[SensitiveParameter] string $publicKey, #[SensitiveParameter] - string $nonce = null + ?string $nonce = null ) { $this->secretKey = $secretKey; $this->publicKey = $publicKey; @@ -128,7 +128,7 @@ public function encrypt( #[SensitiveParameter] string $message, #[SensitiveParameter] - string $nonce = null + ?string $nonce = null ) : string { return \sodium_crypto_box( $message, @@ -155,7 +155,7 @@ public function decrypt( #[SensitiveParameter] string $ciphertext, #[SensitiveParameter] - string $nonce = null + ?string $nonce = null ) : false | string { return \sodium_crypto_box_open( $ciphertext, diff --git a/src/GenericHash.php b/src/GenericHash.php index c6fe1b1..4b188d3 100644 --- a/src/GenericHash.php +++ b/src/GenericHash.php @@ -103,7 +103,7 @@ protected function validateHashLength(int $length) : void public function signature( #[SensitiveParameter] string $message, - int $hashLength = null + ?int $hashLength = null ) : string { return Utils::bin2base64( $this->makeHash($message, $hashLength), @@ -129,7 +129,7 @@ public function verify( string $message, #[SensitiveParameter] string $signature, - int $hashLength = null + ?int $hashLength = null ) : bool { return \hash_equals( $this->makeHash($message, $hashLength), @@ -149,7 +149,7 @@ public function verify( * * @return string */ - protected function makeHash(#[SensitiveParameter] string $message, int $length = null) : string + protected function makeHash(#[SensitiveParameter] string $message, ?int $length = null) : string { if ($length !== null) { $this->validateHashLength($length); diff --git a/src/Password.php b/src/Password.php index abafdec..38e73dc 100644 --- a/src/Password.php +++ b/src/Password.php @@ -58,8 +58,8 @@ class Password public static function hash( #[SensitiveParameter] string $password, - int $opslimit = null, - int $memlimit = null + ?int $opslimit = null, + ?int $memlimit = null ) : string { $opslimit ??= static::getOpsLimit(); $memlimit ??= static::getMemLimit(); @@ -84,8 +84,8 @@ public static function hash( public static function needsRehash( #[SensitiveParameter] string $hash, - int $opslimit = null, - int $memlimit = null + ?int $opslimit = null, + ?int $memlimit = null ) : bool { $opslimit ??= static::getOpsLimit(); $memlimit ??= static::getMemLimit();