Add Stringable interface by nicolas-grekas · Pull Request #5083 · php/php-src
Just as a heads up, I rebased and force pushed.
Regarding the automatic implementation of Stringable, I initially thought we could simply add this at the very end of inheritance ... but then I realized that this automatic implementation could be relevant for variance checks:
class Foo {
public function test(): Stringable {}
}
class Bar extends Foo {
public function test(): Bar {}
public function __toString() {}
}
Which would be legal if Bar automatically implements Stringable. To allow that, we need to add it as a proper interface during initial compilation.