Skip to content

Phpstan complains that a method returns a child where it expected a parent #3951

@orklah

Description

@orklah

Bug report

In the following code:
https://phpstan.org/r/934fcc4c-109b-4696-b1f4-4586a04cbcb9

PHPStan says:
Method A::filterSubject() should return TSubject of Subject|null but returns Filterable|null.

but Filterable is a child of Subject so it should be valid code

The error message isn't entirely true either, at line 19, we can return something that isn't a Filterable.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions