Skip to content

Types not being pulled from @phpstan-type correctly #6556

@dehrk

Description

@dehrk

Bug report

When defining array structure with @phpstan-type, checking some keys using array_key_exists does not correctly determine the type associated.

Code snippet that reproduces the problem

https://phpstan.org/r/2f4d63e8-1e34-4f3d-8d6c-912db0cef960

Expected output

4

PHPStan should be able to determine the types for all defined keys. If the keys in the array are not listed in the PHPStan type, it can determine which keys are missing (https://phpstan.org/r/286792cb-f9ef-4536-8751-84f86217ef69).

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

I love PHPstan! It's helping me get my code ready for PHP8 and making it much easier!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions