Skip to content

preg_match handles preg_quoted string as unsafe/unknown strings even tho they are safe #11332

@Seldaek

Description

@Seldaek

Bug report

@staabm another one.. I am not sure how easy to fix but technically something inside a pattern that is preg_quoted is safe (as long as the pattern delimiter are metacharacters, or curly/square braces/parenthesis).

So the above pattern in the reproducer could be processed just like the second one (well I guess the return value of preg_quote should be assumed to be '' for string and 'x' for non-empty-string, for safety in further regex pattern processing we don't want to mark something as not empty if we are not sure like '#('.preg_quote('').')#' might be matching nothing).

Code snippet that reproduces the problem

https://phpstan.org/r/c2d6118d-b040-42e4-a5b1-ec4fb0f48fd3

Expected output

See above

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