Skip to content

Wrong type inference non-falsy-string for preg_match group containing start/end meta characters #12297

@InvisibleSmiley

Description

@InvisibleSmiley

Bug report

When a preg_match group contains ^ or $, the type of the group in the matches result array is inferred as non-falsy-string, indicating that it cannot be string '0'. That is wrong.

Code snippet that reproduces the problem

https://phpstan.org/r/b2ba615b-0e37-45ba-8330-e428144907c1

Expected output

No issues

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions