8000 [Finder] Glob::toRegex is duplicated · Issue #14075 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Finder] Glob::toRegex is duplicated #14075

@jaytaph

Description

@jaytaph

It seems that the toRegex method in Finder\Glob.php is duplicated in the Finder\Expression\Glob.php. There are some small differences in the code though:

   <     public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true)
   ---
   >     public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
   7c7
   <         $sizeGlob = strlen($glob);
   ---
   >         $sizeGlob = strlen($this->pattern);
   9c9
   <             $car = $glob[$i];
   ---
   >             $car = $this->pattern[$i];
   55c55
   <         return '#^'.$regex.'$#';
   ---
   >         return new Regex('^'.$regex.'$');

None which seems strange. It might be a good idea to actually remove the toRegex from the Expression/Glob.php method, and instead use the Glob::toRegex in its place (this file is not unit-tested neither).

Any suggestions / comments on this? I'm happy to create a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0