Fix keg version in Formula#to_hash

Closes #28550.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>