From 1b0c216a7b31ad0da84fe18dbf103dae96322568 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 9 Nov 2020 14:45:33 +0100 Subject: [PATCH] Add proper return types to CryptoUtil --- wcfsetup/install/files/lib/util/CryptoUtil.class.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/wcfsetup/install/files/lib/util/CryptoUtil.class.php b/wcfsetup/install/files/lib/util/CryptoUtil.class.php index 120bd37223..2c826d00a7 100644 --- a/wcfsetup/install/files/lib/util/CryptoUtil.class.php +++ b/wcfsetup/install/files/lib/util/CryptoUtil.class.php @@ -19,10 +19,9 @@ final class CryptoUtil { * Signs the given value with the signature secret. * * @param string $value - * @return string * @throws CryptoException */ - public static function getSignature($value) { + public static function getSignature($value): string { if (mb_strlen(SIGNATURE_SECRET, '8bit') < 15) throw new CryptoException('SIGNATURE_SECRET is too short, aborting.'); return hash_hmac('sha256', $value, SIGNATURE_SECRET); @@ -32,9 +31,8 @@ final class CryptoUtil { * Creates a signed (signature + encoded value) string. * * @param string $value - * @return string */ - public static function createSignedString($value) { + public static function createSignedString($value): string { return self::getSignature($value).'-'.Base64::encode($value); } @@ -43,9 +41,8 @@ final class CryptoUtil { * (i.e. consists of a valid signature + encoded value) * * @param string $string - * @return boolean */ - public static function validateSignedString($string) { + public static function validateSignedString($string): bool { $parts = explode('-', $string, 2); if (count($parts) !== 2) return false; list($signature, $value) = $parts; @@ -67,10 +64,9 @@ final class CryptoUtil { * - Returns null if the string is not properly signed. * * @param string $string - * @return null|string * @see \wcf\util\CryptoUtil::validateSignedString() */ - public static function getValueFromSignedString($string) { + public static function getValueFromSignedString($string): ?string { if (!self::validateSignedString($string)) return null; $parts = explode('-', $string, 2); -- 2.20.1