Description

Introduced in PHP 8.0, static return types1 guarantee that a method will return an instance of its object, and not that of a parent.

Syntax

class Foo
{
    public function tralala(): static
    {
        return $this;
    }
}

Footnotes

Footnotes

  1. https://wiki.php.net/rfc/static_return_type