Skip to content

Commit

Permalink
Remove regex and fnmatch again on NodeNameResolver (#4968)
Browse files Browse the repository at this point in the history
* Revert "Fix fixture typo (#4967)"

This reverts commit 76cf20f.

* Revert "[NodeNameResolver] Check regex start delimiter and contains * on NodeNameResolver to use fnmatch() (#4964)"

This reverts commit ef6c8bc.

* fixture

* fixture

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Sep 10, 2023
1 parent 76cf20f commit ead7a25
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 33 deletions.
17 changes: 1 addition & 16 deletions packages/NodeNameResolver/NodeNameResolver.php
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 All @@ -33,7 +31,6 @@ final class NodeNameResolver
public function __construct(
private readonly ClassNaming $classNaming,
private readonly CallAnalyzer $callAnalyzer,
private readonly RegexPatternDetector $regexPatternDetector,
private readonly iterable $nodeNameResolvers = []
) {
}
Expand Down Expand Up @@ -184,19 +181,7 @@ public function isStringName(string $resolvedName, string $desiredName): bool
return $desiredName === $resolvedName;
}

if (strcasecmp($resolvedName, $desiredName) === 0) {
return true;
}

if ($this->regexPatternDetector->isRegexPattern($desiredName)) {
return StringUtils::isMatch($resolvedName, $desiredName);
}

if (str_contains($desiredName, '*')) {
return fnmatch($desiredName, $resolvedName, FNM_NOESCAPE);
}

return false;
return strcasecmp($resolvedName, $desiredName) === 0;
}

private function isCallOrIdentifier(Expr|Identifier $node): bool
Expand Down
2 changes: 2 additions & 0 deletions packages/Parallel/Application/ParallelFileProcessor.php
Expand Up @@ -42,6 +42,7 @@ final class ParallelFileProcessor
* @var int
*/
private const SYSTEM_ERROR_LIMIT = 50;

/**
* The number of chunks a worker can process before getting killed.
* In contrast the jobSize defines the maximum size of a chunk, a worker process at a time.
Expand Down Expand Up @@ -224,6 +225,7 @@ function (array $json) use (
($processSpawner)();
return;
}

if ($jobs === []) {
$this->processPool->quitProcess($processIdentifier);
return;
Expand Down

This file was deleted.

Expand Up @@ -7,10 +7,5 @@

return static function (RectorConfig $rectorConfig): void {
$rectorConfig
->ruleWithConfiguration(StringClassNameToClassConstantRector::class, [
'Nette\*',
'#^PHPStan\\\\Type#',
'Error',
'Exception'
]);
->ruleWithConfiguration(StringClassNameToClassConstantRector::class, ['Nette\*', 'Error', 'Exception']);
};
Expand Up @@ -179,6 +179,10 @@ private function shouldSkip(string $classLikeName): bool
if ($this->nodeNameResolver->isStringName($classLikeName, $classToSkip)) {
return true;
}

if (fnmatch($classToSkip, $classLikeName, FNM_NOESCAPE)) {
return true;
}
}

return false;
Expand Down

0 comments on commit ead7a25

Please sign in to comment.