Skip to content

False-positive expects Bar, Bar|Foo given while using match with collections #7593

@fluffycondor

Description

@fluffycondor

Bug report

Looks like PHPStan thinks there are four code paths may be executed:

  • $fooCollection->add(Foo::class)
  • $fooCollection->add(Bar::class)
  • $barCollection->add(Foo::class)
  • $barCollection->add(Bar::class)

But actually there are only two paths, $fooCollection->add(Foo::class) and $barCollection->add(Bar::class).

Code snippet that reproduces the problem

https://phpstan.org/r/4a41044b-cdcb-4466-9043-a9c050420d4d

Expected output

No errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions