Much ado about null (and a more #PHP-friendly alternative to monads you can use today!)
@mwop Hrm, possibly. I... don't quite grok how they're not both bottom types, though. Other than "never" being "more bottom"? Would void have qualified as a bottom type before never snuck in below it?
@Crell If a parent interface/class defines a non-void, non-null type as the return type, you cannot redefine it as void in the child (PHP considers it an incompatible signature). You CAN redefine it as never, however.
Essentially, we never had a bottom type before.
@Crell Create an interface that defines a method that returns a type (e.g. int, object, etc. — anything but void, null, or mixed), and then create an implementation that uses void. This results in a fatal. Switch it to never (PHP 8.1 only), and it's valid.
It was one of the reasons for adding the type, and part of why it was also proposed later for arguments. The problem is that the name ("never") as a type for an argument is hard to grok, so that proposal failed.
Open source. Open community. We are dedicated to building and enriching the PHP community.