Skip to content

@phpstan-assert conditional type ignores param default values #9435

@InvisibleSmiley

Description

@InvisibleSmiley

Bug report

PHPStan seems to ignore param default values when analysing conditional types that are part of @phpstan-assert annotations.

The example has just a single param in the conditional type expression but more complex (nested) expressions may use multiple params, all of which would be affected.

The problem also affects both positional and named parameters.

Code snippet that reproduces the problem

https://phpstan.org/r/03bf067f-d92e-479b-a8bf-f1ee9d8bcc03

Expected output

The param type(s) should be inferred correctly even if the param(s) is/are not specified explicitly.

Conditional types in @phpstan-return do not seem to be affected:
https://phpstan.org/r/b7c3a988-f93f-4cbb-a899-abdf8fc82782

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions