axelerant / drupal-quality-checker

Pre-commit code quality checker for Drupal based projects.
https://packagist.org/packages/axelerant/drupal-quality-checker
12 stars 9 forks source link

PHP Warning: preg_match(): Unknown modifier 't' #41

Open zeshanziya opened 5 months ago

zeshanziya commented 5 months ago

I have noticed that when paths in ignore_patterns have a / at the end, it generates the following warning while running GrumPHP:

PHP Warning: preg_match(): Unknown modifier 't' in phar:///var/www/html/vendor/phpro/grumphp-shim/grumphp.phar/vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php on line 53

Solutions: Fix paths for ignore_patterns in grumphp.yml.dist

hussainweb commented 5 months ago

Can you share more information here? Which version of GrumPHP? What was the pattern that you had to fix? Do you have to fix it for all tools or only some of them?

zeshanziya commented 5 months ago

I checked, and it's present in all GrumPHP versions. Yes for all tools ignore_patterns paths. Following are my observations.

So if a path starts with / and ends with / and has multiple directories, it generates a warning.

Examples:

/config/ works fine /web/sites/default/ generates a warning web/sites/default/ works fine /web/sites/default works fine

image
hussainweb commented 5 months ago

So, these patterns are always regexes. As explained in this comment, we must escape the slashes.

This means it is not a bug but we should document this better.

hussainweb commented 5 months ago

Also, the explanation for why paths with slashes inside the string work is in this function.