From: Matthew Wire Date: Thu, 11 Jan 2024 12:46:57 +0000 (+0000) Subject: Fix fatal error when firebase/php-jwt library is 'replaced' in composer X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=645ba6bbff02cd6eff31502d01214d7a2ed01953;p=civicrm-core.git Fix fatal error when firebase/php-jwt library is 'replaced' in composer --- diff --git a/Civi/Crypto/CryptoJwt.php b/Civi/Crypto/CryptoJwt.php index bbc989ce20..0d5455d58e 100644 --- a/Civi/Crypto/CryptoJwt.php +++ b/Civi/Crypto/CryptoJwt.php @@ -60,7 +60,12 @@ class CryptoJwt { * @throws CryptoException */ public function decode($token, $keyTag = 'SIGN') { - $useKeyObj = version_compare(\Composer\InstalledVersions::getVersion('firebase/php-jwt'), '6', '>='); + // Version 6.x+ has 2 parameters, earlier versions had 3 + $reflection = new \ReflectionMethod('Firebase\JWT\JWT::decode'); + $useKeyObj = ($reflection->getNumberOfParameters() === 2) ?? FALSE; + + // Composer\InstalledVersions returns 0 if the library has been replaced using "replace" in composer.json + // $useKeyObj = version_compare(\Composer\InstalledVersions::getVersion('firebase/php-jwt'), '6', '>='); if (!$useKeyObj) { \CRM_Core_Error::deprecatedWarning('Using deprecated version of firebase/php-jwt. Upgrade to 6.x+.'); }