Skip to content

Commit

Permalink
remove unused matchesStringName()
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Sep 9, 2023
1 parent 2397a71 commit 6a88d44
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
17 changes: 0 additions & 17 deletions packages/NodeNameResolver/NodeNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
use Rector\CodingStyle\Naming\ClassNaming;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\NodeAnalyzer\CallAnalyzer;
use Rector\Core\Util\StringUtils;
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
use Rector\NodeNameResolver\Regex\RegexPatternDetector;
use Rector\NodeTypeResolver\Node\AttributeKey;

final class NodeNameResolver
Expand Down Expand Up @@ -221,21 +219,6 @@ public function isStringName(string $resolvedName, string $desiredName): bool
return strtolower($resolvedName) === strtolower($desiredName);
}

public function matchesStringName(string|Identifier $resolvedName, string $desiredNamePattern): bool
{
if ($resolvedName instanceof Identifier) {
$resolvedName = $resolvedName->toString();
}

// // is probably regex pattern
// if ($this->regexPatternDetector->isRegexPattern($desiredNamePattern)) {
// return StringUtils::isMatch($resolvedName, $desiredNamePattern);
// }

// is probably fnmatch
return fnmatch($desiredNamePattern, $resolvedName, FNM_NOESCAPE);
}

private function isCallOrIdentifier(Expr|Identifier $node): bool
{
if ($node instanceof Expr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private function shouldSkip(string $classLikeName): bool
return true;
}

if ($this->nodeNameResolver->matchesStringName($classLikeName, $classToSkip)) {
if (fnmatch($classToSkip, $classLikeName, FNM_NOESCAPE)) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private function shouldSkip(Class_ $class): bool
continue;
}

if (! $this->nodeNameResolver->matchesStringName($className, $transformOnNamespace)) {
if (! fnmatch($transformOnNamespace, $className, FNM_NOESCAPE)) {
return true;
}
}
Expand Down

0 comments on commit 6a88d44

Please sign in to comment.