Use `new` instead of `from_hash` for formula and cask structs by Rylan12 · Pull Request #21377 · Homebrew/brew

Sorbet's default T::Struct::from_hash doesn't actually check to ensure that types match. Instead, let's override this method to use T::Struct::new which does perform type checking to catch additional issues.

I had to fix a few minor types, but otherwise all formulae and casks load successfully from the API, which I tested with Formula.all and Cask::Cask.all in brew irb.

To try to avoid more issues when loading old installed cask JSON data, I've added an exception to the cask handling: if a cask is loaded from JSON that came from the installed caskfile, it will stick with the old method that doesn't enforce types to avoid fatal errors there