| @@ -16,9 +16,9 @@ | ||
| 16 | 16 | 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 |
| 24 | 24 | ``` |
| @@ -47,9 +47,10 @@ | ||
| 47 | 47 | $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 | /* |
| 55 | 56 | NOTE: This will now be an object instead of an associative array. To get |
| @@ -184,9 +185,9 @@ | ||
| 184 | 185 | // Your private key file with passphrase |
| 185 | 186 | // Can be generated with "ssh-keygen -t rsa -m pem" |
| 186 | 187 | $privateKeyFile = '/path/to/key-with-passphrase.pem'; |
| 187 | 188 | |
| 188 | -// Create a private key of type "resource" | |
| 189 | +/** @var OpenSSLAsymmetricKey $privateKey */ | |
| 189 | 190 | $privateKey = openssl_pkey_get_private( |
| 190 | 191 | file_get_contents($privateKeyFile), |
| 191 | 192 | $passphrase |
| 192 | 193 | ); |
| @@ -289,9 +290,9 @@ | ||
| 289 | 290 | $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 |
| 297 | 298 | --------------------- |
| @@ -348,9 +349,9 @@ | ||
| 348 | 349 | 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) { |
| 356 | 357 | // provided algorithm is unsupported OR |
| @@ -378,9 +379,9 @@ | ||
| 378 | 379 | ```php |
| 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) { |
| 386 | 387 | // errors having to do with JWT signature and claims |
| @@ -393,9 +394,9 @@ | ||
| 393 | 394 | 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); |
| 401 | 402 | ``` |