Skip to content

Match arm comparison between class-string<TypeWithGeneric<Generic>> and 'TypeWithSpecific' is always false. #8092

@MetalArend

Description

@MetalArend

Bug report

Combining get_class and/or match arms with generics is giving incorrectly comparison results.

Code snippet that reproduces the problem

PHPStan Try Link

Expected output

The output should at least report that comparing with the class-string<TypeWithSpecific> is always false, instead of trying to compare with TypeWithSpecific directly. Not sure if that might be the source of the bug.
The match arm comparison should not be reported, as TypeWithSpecific is a possible result (and even the only result in this example) of the TypeWithGeneric<Generic> generic.

The second error Parameter #1 $type of method HelloWorld::call() expects TypeWithSpecific, TypeWithGeneric<Generic> given. that is being thrown will probably be fixed if the first error is correctly mitigated, I think.

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

Always. None of this would have been possible 10 years ago, it is amazing that we can nitpick on such deep error reporting ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions