build: Add @phan-var to handle varying return value of hash_hmac

Since php8.0 hash_hmac throws exception and does not return false
Reported by phan running with php8.1

Change-Id: I2374daf5e0954bef91da65454d973ef3d1eb2183
This commit is contained in:
Umherirrender 2023-10-06 19:25:35 +02:00
parent 2f4996cf14
commit 70703bdce3

View file

@ -1044,7 +1044,9 @@ class LoginNotify implements LoggerAwareInterface {
// TODO: would be nice to truncate the hash, but we would need b/c
$res = hash_hmac( 'sha1', $username . '|' . $year . $salt, $this->secret );
'@phan-var string|false $res';
if ( !is_string( $res ) ) {
// Throws ValueError under php8 in case of error, remove this when mininum is php8
throw new UnexpectedValueException( "Hash failed" );
}
$encoded = $year . '-' . $salt . '-' . \Wikimedia\base_convert( $res, 16, 36 );