Skip to content

False-positive Cannot call method on #152

@fluffycondor

Description

@fluffycondor

Bug report

PHPStan 0.12.50

Cannot call method update() on App\Entity\MyEntity|false when it can't be false.

Code snippet that reproduces the problem

/** @var \Doctrine\Common\Collections\Collection<MyEntity> $collection */
if ($collection->isEmpty()) {
    $collection->add($new);
} else {
    $collection->first()->update($new); // Cannot call method update() on App\Entity\MyEntity|false
}

Expected output

There should not be any error, but Cannot call method update() on App\Entity\MyEntity|false raised

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