original_string: public static function toRegex(string $gitignoreFileContent): string
      {
          $gitignoreFileContent = preg_replace('/^[^\\\\]*#.*/', '', $gitignoreFileContent);
          $gitignoreLines = preg_split('/\r\n|\r|\n/', $gitignoreFileContent);
          $gitignoreLines = array_map('trim', $gitignoreLines);
          $gitignoreLines = array_filter($gitignoreLines);
  
          $ignoreLinesPositive = array_filter($gitignoreLines, function (string $line) {
              return !preg_match('/^!/', $line);
          });
  
          $ignoreLinesNegative = array_filter($gitignoreLines, function (string $line) {
              return preg_match('/^!/', $line);
          });
  
          $ignoreLinesNegative = array_map(function (string $line) {
              return preg_replace('/^!(.*)/', '${1}', $line);
          }, $ignoreLinesNegative);
          $ignoreLinesNegative = array_map([__CLASS__, 'getRegexFromGitignore'], $ignoreLinesNegative);
  
          $ignoreLinesPositive = array_map([__CLASS__, 'getRegexFromGitignore'], $ignoreLinesPositive);
          if (empty($ignoreLinesPositive)) {
              return '/^$/';
          }
  
          if (empty($ignoreLinesNegative)) {
              return sprintf('/%s/', implode('|', $ignoreLinesPositive));
          }
  
          return sprintf('/(?=^(?:(?!(%s)).)*$)(%s)/', implode('|', $ignoreLinesNegative), implode('|', $ignoreLinesPositive));
      }
code: public static function toRegex(string $gitignoreFileContent): string
      {
          $gitignoreFileContent = preg_replace('/^[^\\\\]*#.*/', '', $gitignoreFileContent);
          $gitignoreLines = preg_split('/\r\n|\r|\n/', $gitignoreFileContent);
          $gitignoreLines = array_map('trim', $gitignoreLines);
          $gitignoreLines = array_filter($gitignoreLines);
  
          $ignoreLinesPositive = array_filter($gitignoreLines, function (string $line) {
              return !preg_match('/^!/', $line);
          });
  
          $ignoreLinesNegative = array_filter($gitignoreLines, function (string $line) {
              return preg_match('/^!/', $line);
          });
  
          $ignoreLinesNegative = array_map(function (string $line) {
              return preg_replace('/^!(.*)/', '${1}', $line);
          }, $ignoreLinesNegative);
          $ignoreLinesNegative = array_map([__CLASS__, 'getRegexFromGitignore'], $ignoreLinesNegative);
  
          $ignoreLinesPositive = array_map([__CLASS__, 'getRegexFromGitignore'], $ignoreLinesPositive);
          if (empty($ignoreLinesPositive)) {
              return '/^$/';
          }
  
          if (empty($ignoreLinesNegative)) {
              return sprintf('/%s/', implode('|', $ignoreLinesPositive));
          }
  
          return sprintf('/(?=^(?:(?!(%s)).)*$)(%s)/', implode('|', $ignoreLinesNegative), implode('|', $ignoreLinesPositive));
      }
code_tokens: public static function toRegex ( string $ gitignoreFileContent ) : string { $ gitignoreFileContent = preg_replace ( '/^[^\\\\]*#.*/' , '' , $ gitignoreFileContent ) ; $ gitignoreLines = preg_split ( '/\r\n|\r|\n/' , $ gitignoreFileContent ) ; $ gitignoreLines = array_map ( 'trim' , $ gitignoreLines ) ; $ gitignoreLines = array_filter ( $ gitignoreLines ) ; $ ignoreLinesPositive = array_filter ( $ gitignoreLines , function ( string $ line ) { return ! preg_match ( '/^!/' , $ line ) ; } ) ; $ ignoreLinesNegative = array_filter ( $ gitignoreLines , function ( string $ line ) { return preg_match ( '/^!/' , $ line ) ; } ) ; $ ignoreLinesNegative = array_map ( function ( string $ line ) { return preg_replace ( '/^!(.*)/' , '${1}' , $ line ) ; } , $ ignoreLinesNegative ) ; $ ignoreLinesNegative = array_map ( [ __CLASS__ , 'getRegexFromGitignore' ] , $ ignoreLinesNegative ) ; $ ignoreLinesPositive = array_map ( [ __CLASS__ , 'getRegexFromGitignore' ] , $ ignoreLinesPositive ) ; if ( empty ( $ ignoreLinesPositive ) ) { return '/^$/' ; } if ( empty ( $ ignoreLinesNegative ) ) { return sprintf ( '/%s/' , implode ( '|' , $ ignoreLinesPositive ) ) ; } return sprintf ( '/(?=^(?:(?!(%s)).)*$)(%s)/' , implode ( '|' , $ ignoreLinesNegative ) , implode ( '|' , $ ignoreLinesPositive ) ) ; }
docstring: Returns a regexp which is the equivalent of the gitignore pattern.
  
  @param string $gitignoreFileContent
  
  @return string The regexp
docstring_tokens: Returns a regexp which is the equivalent of the gitignore pattern .