[RFC] Never For Argument Types

From: Date: Fri, 13 Aug 2021 23:27:12 +0000
Subject: [RFC] Never For Argument Types
Groups: php.internals 
Request: Send a blank email to internals+get-115712@lists.php.net to get a copy of this message
Hey internals, I've been working on the draft for my operator overloading RFC, and in doing so I encountered a separate change that I would like to see. That is, the use of never as an argument type for interfaces. Since arguments in PHP are contravariant to preserve Liskov substitution, never as the bottom type should indicate that implementing classes can require any type combination they want. This is in fact consistent with type theory and set theory, and is how the bottom type is treated in several other languages. In this case, the bottom type would be used to indicate covariant parameter polymorphism while not conflicting with LSP. This would provide a sort of minimal form of generics to PHP without the issues that actual generics present from an implementation perspective. It would not, however, restrict or hinder any future RFC for generics. This is at the first draft stage, and I currently have the RFC on a github repo to allow for easy contribution and collaboration. Any feedback is greatly appreciated. https://github.com/JordanRL/never-argument-type Jordan

« previous php.internals (#115712) next »