StringUtils: Add a utility for checking if a string is a valid regex
authorDaimona Eaytoy <daimona.wiki@gmail.com>
Wed, 5 Sep 2018 14:20:13 +0000 (16:20 +0200)
committerDaimona Eaytoy <daimona.wiki@gmail.com>
Wed, 18 Sep 2019 09:46:29 +0000 (09:46 +0000)
commitc14571ba26edbe26606127fdf89cd9793a7488ab
tree3042776dafb1e0e89a76c01b91c8197f3963f21f
parent2083ba21997bc214c34a5a1edbeef61b0cb98981
StringUtils: Add a utility for checking if a string is a valid regex

There's no function to check if a string is a valid regex, and doing it
via preg_match requires error suppression, often performed with @. This
isn't however a good practice, and suppressing errors via functions is
not a one line solution. Adding an utility function would probably be a
benefit for several use cases (try to grep '@preg_match' for a few of
them).

Change-Id: I257a096319f1ec13441e9f745dcd22545fdd5cc6
includes/libs/StringUtils.php
tests/phpunit/includes/libs/StringUtilsTest.php