whateverthing.com

March 13, 2020

With PHP's recent focus on stricter type handling comes some new terminology that might be intimidating to some and confusing to others.

Two new terms, "contravariant parameters" and "covariant returns", describe how derived classes and interface implementations can widen and narrow the declared types of their parent interface or class.

Back in the code-slinging, devil-may-care olden days of PHP (up to version 4), we didn't have to worry about this stuff, because the language's loosey-goosey typing "solved" it for us. We could come up with any horrendously tangled mess we wanted to.

But now, PHP is growing up. It has Opinions™. And those opinions mean that more care needs to be taken when smashing rocks together to craft our classes.