Skip to content

Problem with @return static #3523

@MidnightDesign

Description

@MidnightDesign

See https://phpstan.org/r/98a3d03f-add8-407f-ac45-69ac58dbba7e

<?php declare(strict_types = 1);

interface FooInterface
{
    /**
     * @return static
     */
    public function deserialize();
}

final class Foo implements FooInterface
{
    public function deserialize(): self
    {
        return new self();
    }
}

Expected behavior:
No errors

Actual behavior:
I get the error

Return type (Foo) of method Foo::deserialize() should be covariant with return type (static(FooInterface)) of method FooInterface::deserialize()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions