symfony / polyfill

PHP polyfills

Home Page:https://symfony.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Polyfill for fnmatch()

Chi-teck opened this issue · comments

commented

It would be useful to have a polyfill for fnmatch.

fnmatch is a way faster than preg_match but unfortunately it is not available on non-posix environments. That makes projects that aim to support a large range of environments to avoid usage of fnmatch.
https://www.drupal.org/project/drupal/issues/2620576

With this much complexity, tests for this function are gonna be quite interesting.

One thing I'm wondering is why PHP does not use its own fnmatch implementation (the one used on windows) for other non-POSIX platforms.
@nikic any idea about that ?

The C implementation of fnmatch for Windows in the PHP code is at https://github.com/php/php-src/blob/2d1bf6970daef6a538a1f61334c81da584a6cd07/win32/fnmatch.c
This might also be an option to implement it, in case this algorithm can be faster than a regex (not sure that's the case when the algorithm is in PHP)

@stof Don't think there's any particular reason, most likely nobody bothered. First time I'm hearing about this function.

@Chi-teck up to submit a PR to php-src and here maybe?

commented

@nicolas-grekas sorry, I don't have free time for this.

PR welcome when anyone has time to work on this. Closing meanwhile.