Skip to content

Conditional return type including template type resolved in wrong place #12333

Open
@jankal

Description

@jankal

Bug report

I am returning a class-string from a method which could also return null in the default generic case (using a conditional return type declaration). The returned class-string type is not checked in the context of the child class but in the generic context of the parent/definer and thus not part of the generic template variable.

Code snippet that reproduces the problem

https://phpstan.org/r/ea335711-73a7-4d4e-9647-9212eef29f75

Expected output

This code shouldn't have any issues as DeleteActionType implements DataClassAwareFormTypeInterface<DeleteActionParameters> and DeleteActionParameters is of Struct

Did PHPStan help you today? Did it make you happy in any way?

Most of the time, PHPStan is more intelligent than I am - discovering issues with covariance and contravariance I otherwise would've missed :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions