HHVM throws a fatal error when $key is not a string (unlike $data which
is typecast), so we might as well as throw an exception so that
at least we have a stack trace.
Bug: T126316
Change-Id: Iad9a499b51647c7dbcd58e9ab7ac8e8cb6359bba
* @return string An hmac hash of the data + key
*/
public static function hmac( $data, $key, $raw = true ) {
+ if ( !is_string( $key ) ) {
+ // a fatal error in HHVM; an exception will at least give us a stack trace
+ throw new InvalidArgumentException( 'Invalid key type: ' . gettype( $key ) );
+ }
return hash_hmac( self::hashAlgo(), $data, $key, $raw );
}