Skip to content

Invalid return type with @return $this and @phpstan-self-out #8275

@jrmajor

Description

@jrmajor

Bug report

When a method is annotated with @return $this and @phpstan-self-out, its return type should be the one specified in @phpstan-self-out, as by the time the method returns, self is already mutated.

Ping @rvanvelzen, as I think you're the one who introduced this feature :)

Code snippet that reproduces the problem

https://phpstan.org/r/b37815cf-55ce-4e76-8e65-9721417b1dfb

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions