Skip to content

Warn when preg_quote is missing the pattern delimiter argument if it is not a standard one #11338

@Seldaek

Description

@Seldaek

Feature request

The first pattern here warns because you end up with a delimiter in the pattern which is not escaped by preg_quote as & is not a metacharacter (only . \ + * ? [ ^ ] $ ( ) { } = ! < > | : - # are escaped).

https://3v4l.org/1J7nFF

PHPStan processes this fine https://phpstan.org/r/c8aea561-2341-418a-b21c-b7d3f7332d4d as it assumes preg_quote will take care of it, but this first one is actually not safe.

See also phpstan/phpstan-src#3233 (review)

cc @staabm

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