@@ -17,7 +17,7 @@ composer require firebase/php-jwt
17
17
```
18
18
19
19
Optionally, install the ` paragonie/sodium_compat ` package from composer if your
20
- php is < 7.2 or does not have libsodium installed:
20
+ php env does not have libsodium installed:
21
21
22
22
``` bash
23
23
composer require paragonie/sodium_compat
@@ -48,7 +48,8 @@ $decoded = JWT::decode($jwt, new Key($key, 'HS256'));
48
48
print_r($decoded);
49
49
50
50
// Pass a stdClass in as the third parameter to get the decoded header values
51
- $decoded = JWT::decode($jwt, new Key($key, 'HS256'), $headers = new stdClass());
51
+ $headers = new stdClass();
52
+ $decoded = JWT::decode($jwt, new Key($key, 'HS256'), $headers);
52
53
print_r($headers);
53
54
54
55
/*
@@ -290,7 +291,7 @@ $jwks = ['keys' => []];
290
291
291
292
// JWK::parseKeySet($jwks) returns an associative array of **kid** to Firebase\JWT\Key
292
293
// objects. Pass this as the second parameter to JWT::decode.
293
- JWT::decode($payload , JWK::parseKeySet($jwks));
294
+ JWT::decode($jwt , JWK::parseKeySet($jwks));
294
295
```
295
296
296
297
Using Cached Key Sets
@@ -349,7 +350,7 @@ use InvalidArgumentException;
349
350
use UnexpectedValueException;
350
351
351
352
try {
352
- $decoded = JWT::decode($payload , $keys);
353
+ $decoded = JWT::decode($jwt , $keys);
353
354
} catch (InvalidArgumentException $e) {
354
355
// provided key/key-array is empty or malformed.
355
356
} catch (DomainException $e) {
@@ -379,7 +380,7 @@ like this:
379
380
use Firebase\JWT\JWT;
380
381
use UnexpectedValueException;
381
382
try {
382
- $decoded = JWT::decode($payload , $keys);
383
+ $decoded = JWT::decode($jwt , $keys);
383
384
} catch (LogicException $e) {
384
385
// errors having to do with environmental setup or malformed JWT Keys
385
386
} catch (UnexpectedValueException $e) {
@@ -394,7 +395,7 @@ instead, you can do the following:
394
395
395
396
``` php
396
397
// return type is stdClass
397
- $decoded = JWT::decode($payload , $keys);
398
+ $decoded = JWT::decode($jwt , $keys);
398
399
399
400
// cast to array
400
401
$decoded = json_decode(json_encode($decoded), true);
0 commit comments