On Thursday 02 April 2026 16:23:03 (+02:00), Matthew Weier O'Phinney wrote:
> If you define mixed, you cannot have a void or never return.
We can't speak for Liskov (only she can), but as far as stable PHP is
concerned never is actually fine, and should also stand a common
interpretation of LSP, as never is the bottom type and henceforth a
specialization of mixed. (Some may go for void, too, but that is far more
abstract and does not work conceptually in PHP if I'm not mistaken.)
Furthermore, the PHP runtime also guarantees that any function can never
return, not only by the never return type.
So it's at least irrelevant to implement a new throwable via an invocable
mixed interface or never, the invocation in the runtime guarantees the
higher contract to the return:
<?php
interface invocable {
public function __invoke(): mixed;
}
$o = new class implements invocable {
public function __invoke(): never {}
};
$o();
Interface violation normally yields a compile error, not a type error,
nowadays.
So if you think that is an error, the discussion should have brought
something to the table.
-- hakre