code: private static function firstWildcardInPattern($pattern)
      {
          $wildcards = ['*', '?', '[', '\\'];
          $wildcardSearch = function ($r, $c) use ($pattern) {
              $p = strpos($pattern, $c);
  
              return $r === false ? $p : ($p === false ? $r : min($r, $p));
          };
  
          return array_reduce($wildcards, $wildcardSearch, false);
      }
docs: Searches for the first wildcard character in the pattern.
  @param string $pattern the pattern to search in
  @return int|bool position of first wildcard character or false if not found