Skip to content

Match expression against gettype does not work as expected #8614

@web-fu

Description

@web-fu

Bug report

Trying to match against gettype does not work as expected.
This problem is maybe related also to this:
#4451

Code snippet that reproduces the problem

https://phpstan.org/r/db68feed-2dbb-43b8-bbb5-f7acbc65ef9e

Expected output

This code handle all possible results, following the function definition:

#[Pure]
#[ExpectedValues([
    "boolean", "integer", "double", "string", "array", "object", "resource", "NULL", "unknown type", "resource (closed)"
])]
function gettype(mixed $value): string {}

PHPStan also does not seems to understand that in line 11 the type of $value is narrowed and cannot be object or array

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions