Skip to content

False-positive "will always evaluate to true" on context-dependent types #7914

@fluffycondor

Description

@fluffycondor

Bug report

There are assertions that prove something is X, but doesn't prove otherwise. That means not all X pass this assertion.
If one passes an already known X to that kind of assertion, PHPStan yields false-positive will always evaluate to true. The analyzer doesn't check the context.

Code snippet that reproduces the problem

https://phpstan.org/r/1912878d-c976-4619-88a5-7d59f226a00d

Expected output

No errors.
ctype_digit proves it's a numeric-string, but doesn't prove otherwise.
https://github.com/phpstan/phpstan-src/blob/1.8.x/src/Type/Php/CtypeDigitFunctionTypeSpecifyingExtension.php#L46

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions