Skip to content

Commit eadccb5

Browse files
committed
Refactor substr calls to remove null parameters and improve code clarity
1 parent 78da15c commit eadccb5

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

Console/KeyFileLoaderCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected function configure(): void
2222
{
2323
parent::configure();
2424
$this->addArgument('file', InputArgument::REQUIRED, 'Filename of the key.')
25-
->addOption('secret', 's', InputOption::VALUE_OPTIONAL, 'Secret if the key is encrypted.', null);
25+
->addOption('secret', 's', InputOption::VALUE_OPTIONAL, 'Secret if the key is encrypted.');
2626
}
2727

2828
#[Override]

Console/P12CertificateLoaderCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected function configure(): void
2222
{
2323
parent::configure();
2424
$this->addArgument('file', InputArgument::REQUIRED, 'Filename of the P12 certificate.')
25-
->addOption('secret', 's', InputOption::VALUE_OPTIONAL, 'Secret if the key is encrypted.', null);
25+
->addOption('secret', 's', InputOption::VALUE_OPTIONAL, 'Secret if the key is encrypted.');
2626
}
2727

2828
#[Override]

Core/Util/ECSignature.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private static function preparePositiveInteger(string $data): string
9797

9898
while (str_starts_with($data, self::ASN1_NEGATIVE_INTEGER)
9999
&& substr($data, 2, self::BYTE_SIZE) <= self::ASN1_BIG_INTEGER_LIMIT) {
100-
$data = substr($data, 2, null);
100+
$data = substr($data, 2);
101101
}
102102

103103
return $data;

Encryption/Algorithm/KeyEncryption/Util/RSACrypt.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static function decryptWithRSA15(RSAKey $key, string $c): string
9898
throw new InvalidArgumentException('Unable to decrypt');
9999
}
100100
$ps = substr($em, 2, (int) strpos($em, chr(0), 2) - 2);
101-
$m = substr($em, strlen($ps) + 3, null);
101+
$m = substr($em, strlen($ps) + 3);
102102
if (strlen($ps) < 8) {
103103
throw new InvalidArgumentException('Unable to decrypt');
104104
}

KeyManagement/Analyzer/UsageAnalyzer.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,18 @@ public function analyze(JWK $jwk, MessageBag $bag): void
2929
if ($jwk->has('key_ops')) {
3030
$key_ops = $jwk->get('key_ops');
3131
if (! is_array($key_ops)) {
32-
$bag->add(
33-
Message::high(
34-
'The parameter "key_ops" must be an array of key operation values.'
35-
)
36-
);
32+
$bag->add(Message::high('The parameter "key_ops" must be an array of key operation values.'));
3733
} else {
38-
$allowedOps = ['sign', 'verify', 'encrypt', 'decrypt', 'wrapKey', 'unwrapKey', 'deriveKey', 'deriveBits'];
34+
$allowedOps = [
35+
'sign',
36+
'verify',
37+
'encrypt',
38+
'decrypt',
39+
'wrapKey',
40+
'unwrapKey',
41+
'deriveKey',
42+
'deriveBits',
43+
];
3944
$unsupportedOps = array_diff($key_ops, $allowedOps);
4045
if ($unsupportedOps !== []) {
4146
$bag->add(

Signature/Algorithm/Util/RSA.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private static function verifyEMSAPSS(string $m, string $em, int $emBits, Hash $
182182
if (ord($db[$temp]) !== 1) {
183183
throw new InvalidArgumentException();
184184
}
185-
$salt = substr($db, $temp + 1, null); // should be $sLen long
185+
$salt = substr($db, $temp + 1); // should be $sLen long
186186
$m2 = "\0\0\0\0\0\0\0\0" . $mHash . $salt;
187187
$h2 = $hash->hash($m2);
188188

0 commit comments

Comments
 (0)