Skip to content

isset condition doesn't refine type #9908

@Jean85

Description

@Jean85

Bug report

I was trying to solve a PHPStan error in my code, where I had to remap a type of an optional array key.
I used if (isset($a['key'])) { ... } to catch the case and completely rewrite that value, but PHPStan still considers the "bad" value a possible type for key.

Code snippet that reproduces the problem

https://phpstan.org/r/c29618f1-5aa6-4295-b15f-b9382d014620

Expected output

I would expect no error, since string should no longer be a possible type after the if

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

Totally! It's guiding me through a heavy refactoring!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions