Skip to content

PHP 7.3 and PCRE2 #2741

@jkbzh

Description

@jkbzh

Hi,

PHP 7.3 migrated from PCRE to PCRE2 . PCRE2 is stricter and requires escaping of hiphens in regular expressions. This is not detected by PHPCS. If this makes sense to you, could it be possible to add a test for hiphens and other characters that need to be escaped so that the following sample would raise a REGEXP warning when running phpcs?

<?php

$tag="j";

if (preg_match("/^[\w-:]+$/", $tag)) {
    print "match";
} else {
    print "no match";
}

PHP 7.3 on the above code gives:
Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /usr/local/src/test.php3 on line 5

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions