Skip to content

Commit 628c41d

Browse files
committed
refactor: cs fix
1 parent 2f58622 commit 628c41d

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

app/Config/Encryption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Encryption extends BaseConfig
3030
* If you want to enable decryption using previous keys, set them here.
3131
* See the user guide for more info.
3232
*/
33-
public string|array $previousKeys = '';
33+
public array|string $previousKeys = '';
3434

3535
/**
3636
* --------------------------------------------------------------------------

system/Encryption/Encryption.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ class Encryption
5656
/**
5757
* Array or Comma-separated list of previous keys for fallback decryption.
5858
*
59-
* @var string|array<string>
59+
* @var list<string>|string
6060
*/
61-
protected string|array $previousKeys = '';
61+
protected array|string $previousKeys = '';
6262

6363
/**
6464
* The derived HMAC key

system/Encryption/Handlers/OpenSSLHandler.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class OpenSSLHandler extends BaseHandler
5959
/**
6060
* List of previous keys for fallback decryption.
6161
*/
62-
protected string|array $previousKeys = '';
62+
protected array|string $previousKeys = '';
6363

6464
/**
6565
* Whether the cipher-text should be raw. If set to false, then it will be base64 encoded.
@@ -133,11 +133,12 @@ public function decrypt($data, #[SensitiveParameter] $params = null)
133133
}
134134

135135
// Only use fallback keys if no custom key was provided in params
136-
$useFallback = !isset($params['key']);
136+
$useFallback = ! isset($params['key']);
137137

138138
$attemptDecrypt = function ($key) use ($data) {
139139
try {
140140
$result = $this->decryptWithKey($data, $key);
141+
141142
return ['success' => true, 'data' => $result];
142143
} catch (EncryptionException $e) {
143144
return ['success' => false, 'exception' => $e];
@@ -153,7 +154,7 @@ public function decrypt($data, #[SensitiveParameter] $params = null)
153154
$originalException = $result['exception'];
154155

155156
// If primary key failed and fallback is allowed, try previous keys
156-
if ($useFallback && !empty($this->previousKeys)) {
157+
if ($useFallback && ! empty($this->previousKeys)) {
157158
foreach ($this->previousKeys as $previousKey) {
158159
$fallbackResult = $attemptDecrypt($previousKey);
159160

system/Encryption/Handlers/SodiumHandler.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace CodeIgniter\Encryption\Handlers;
1515

1616
use CodeIgniter\Encryption\Exceptions\EncryptionException;
17-
use phpDocumentor\Reflection\PseudoTypes\NonEmptyString;
1817
use SensitiveParameter;
1918

2019
/**
@@ -35,7 +34,7 @@ class SodiumHandler extends BaseHandler
3534
/**
3635
* List of previous keys for fallback decryption.
3736
*/
38-
protected string|array $previousKeys = '';
37+
protected array|string $previousKeys = '';
3938

4039
/**
4140
* Block size for padding message.
@@ -87,15 +86,17 @@ public function decrypt($data, #[SensitiveParameter] $params = null)
8786
}
8887

8988
// Only use fallback keys if no custom key was provided in params
90-
$useFallback = !isset($params['key']);
89+
$useFallback = ! isset($params['key']);
9190

9291
$attemptDecrypt = function ($key) use ($data) {
9392
try {
9493
$result = $this->decryptWithKey($data, $key);
9594
sodium_memzero($key);
95+
9696
return ['success' => true, 'data' => $result];
9797
} catch (EncryptionException $e) {
9898
sodium_memzero($key);
99+
99100
return ['success' => false, 'exception' => $e];
100101
}
101102
};
@@ -109,7 +110,7 @@ public function decrypt($data, #[SensitiveParameter] $params = null)
109110
$originalException = $result['exception'];
110111

111112
// If primary key failed and fallback is allowed, try previous keys
112-
if ($useFallback && !empty($this->previousKeys)) {
113+
if ($useFallback && ! empty($this->previousKeys)) {
113114
foreach ($this->previousKeys as $previousKey) {
114115
$fallbackResult = $attemptDecrypt($previousKey);
115116

0 commit comments

Comments
 (0)