Skip to content

Commit c68f2a7

Browse files
authored
chore: fix styles and phpstan (#440)
1 parent 64ed2e5 commit c68f2a7

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/JWK.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private static function createPemFromCrvAndXYCoordinates(string $crv, string $x,
179179
) .
180180
self::encodeDER(
181181
self::ASN1_BIT_STRING,
182-
chr(0x00) . chr(0x04)
182+
\chr(0x00) . \chr(0x04)
183183
. JWT::urlsafeB64Decode($x)
184184
. JWT::urlsafeB64Decode($y)
185185
)
@@ -295,21 +295,21 @@ private static function encodeOID(string $oid): string
295295
// Get the first octet
296296
$first = (int) array_shift($octets);
297297
$second = (int) array_shift($octets);
298-
$oid = chr($first * 40 + $second);
298+
$oid = \chr($first * 40 + $second);
299299

300300
// Iterate over subsequent octets
301301
foreach ($octets as $octet) {
302302
if ($octet == 0) {
303-
$oid .= chr(0x00);
303+
$oid .= \chr(0x00);
304304
continue;
305305
}
306306
$bin = '';
307307

308308
while ($octet) {
309-
$bin .= chr(0x80 | ($octet & 0x7f));
309+
$bin .= \chr(0x80 | ($octet & 0x7f));
310310
$octet >>= 7;
311311
}
312-
$bin[0] = $bin[0] & chr(0x7f);
312+
$bin[0] = $bin[0] & \chr(0x7f);
313313

314314
// Convert to big endian if necessary
315315
if (pack('V', 65534) == pack('L', 65534)) {

src/JWT.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -301,20 +301,20 @@ private static function verify(
301301
'OpenSSL error: ' . \openssl_error_string()
302302
);
303303
case 'sodium_crypto':
304-
if (!\function_exists('sodium_crypto_sign_verify_detached')) {
305-
throw new DomainException('libsodium is not available');
306-
}
307-
if (!\is_string($keyMaterial)) {
308-
throw new InvalidArgumentException('key must be a string when using EdDSA');
309-
}
310-
try {
311-
// The last non-empty line is used as the key.
312-
$lines = array_filter(explode("\n", $keyMaterial));
313-
$key = base64_decode((string) end($lines));
314-
return sodium_crypto_sign_verify_detached($signature, $msg, $key);
315-
} catch (Exception $e) {
316-
throw new DomainException($e->getMessage(), 0, $e);
317-
}
304+
if (!\function_exists('sodium_crypto_sign_verify_detached')) {
305+
throw new DomainException('libsodium is not available');
306+
}
307+
if (!\is_string($keyMaterial)) {
308+
throw new InvalidArgumentException('key must be a string when using EdDSA');
309+
}
310+
try {
311+
// The last non-empty line is used as the key.
312+
$lines = array_filter(explode("\n", $keyMaterial));
313+
$key = base64_decode((string) end($lines));
314+
return sodium_crypto_sign_verify_detached($signature, $msg, $key);
315+
} catch (Exception $e) {
316+
throw new DomainException($e->getMessage(), 0, $e);
317+
}
318318
case 'hash_hmac':
319319
default:
320320
if (!\is_string($keyMaterial)) {
@@ -510,7 +510,7 @@ private static function signatureToDER(string $sig): string
510510
{
511511
// Separate the signature into r-value and s-value
512512
$length = max(1, (int) (\strlen($sig) / 2));
513-
list($r, $s) = \str_split($sig, $length > 0 ? $length : 1);
513+
list($r, $s) = \str_split($sig, $length);
514514

515515
// Trim leading zeros
516516
$r = \ltrim($r, "\x00");

0 commit comments

Comments
 (0)