@@ -98,7 +98,7 @@ public static function decode(
98
98
throw new InvalidArgumentException ('Key may not be empty ' );
99
99
}
100
100
$ tks = \explode ('. ' , $ jwt );
101
- if (\count ($ tks ) != 3 ) {
101
+ if (\count ($ tks ) !== 3 ) {
102
102
throw new UnexpectedValueException ('Wrong number of segments ' );
103
103
}
104
104
list ($ headb64 , $ bodyb64 , $ cryptob64 ) = $ tks ;
@@ -136,7 +136,7 @@ public static function decode(
136
136
// OpenSSL expects an ASN.1 DER sequence for ES256/ES384 signatures
137
137
$ sig = self ::signatureToDER ($ sig );
138
138
}
139
- if (!self ::verify ("$ headb64. $ bodyb64 " , $ sig , $ key ->getKeyMaterial (), $ header ->alg )) {
139
+ if (!self ::verify ("$ { headb64} . $ { bodyb64} " , $ sig , $ key ->getKeyMaterial (), $ header ->alg )) {
140
140
throw new SignatureInvalidException ('Signature verification failed ' );
141
141
}
142
142
@@ -293,7 +293,8 @@ private static function verify(
293
293
$ success = \openssl_verify ($ msg , $ signature , $ keyMaterial , $ algorithm ); // @phpstan-ignore-line
294
294
if ($ success === 1 ) {
295
295
return true ;
296
- } elseif ($ success === 0 ) {
296
+ }
297
+ if ($ success === 0 ) {
297
298
return false ;
298
299
}
299
300
// returns 1 on success, 0 on failure, -1 on error.
@@ -610,7 +611,7 @@ private static function readDER(string $der, int $offset = 0): array
610
611
}
611
612
612
613
// Value
613
- if ($ type == self ::ASN1_BIT_STRING ) {
614
+ if ($ type === self ::ASN1_BIT_STRING ) {
614
615
$ pos ++; // Skip the first contents octet (padding indicator)
615
616
$ data = \substr ($ der , $ pos , $ len - 1 );
616
617
$ pos += $ len - 1 ;
0 commit comments