Skip to content

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

Closed

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

Activity

  1. ondrejmirtes commented on Dec 20, 2024

    @ondrejmirtes
    Member
  2. github-actions commented on Jan 21, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  3. locked as resolved and limited conversation to collaborators on Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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