It looks like Facebook had your exact problem; you want Hack:
It's based on PHP, but adds:
Expressive type system with generics:
https://docs.hhvm.com/hack/types/generic-types
Specialized collections: vec, dict, keyset
https://docs.hhvm.com/hack/types/arrays
Templating solution similar to JSX: XHP