You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
jaytaph
changed the title
[Finder] Glob::toRegex is duplicate
[Finder] Glob::toRegex is duplicated
Mar 26, 2015
This PR was merged into the 2.7 branch.
Discussion
----------
[Finder] Removed duplicated toRegex() code
This patch removes duplicated `toRegex()` code by using the already existing `Glob` class. As this class wasn't unit-tested to begin with, this duplication also makes sure this class is tested properly.
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #14075
| License | MIT
Commits
-------
6150c3a Removed duplicated toRegex() code
It seems that the
toRegex
method inFinder\Glob.php
is duplicated in theFinder\Expression\Glob.php
. There are some small differences in the code though:None which seems strange. It might be a good idea to actually remove the
toRegex
from theExpression/Glob.php
method, and instead use theGlob::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.
The text was updated successfully, but these errors were encountered: