Skip to content

Commit

Permalink
[Performance] Remove regex for check start with big letter on ShortNa…
Browse files Browse the repository at this point in the history
…meResolver (#5084)
  • Loading branch information
samsonasik committed Sep 26, 2023
1 parent 50eb9ef commit b483230
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions rules/CodingStyle/ClassNameImport/ShortNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Rector\CodingStyle\NodeAnalyzer\UseImportNameMatcher;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\Core\Util\StringUtils;
use Rector\Core\ValueObject\Application\File;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
Expand All @@ -33,12 +32,6 @@
*/
final class ShortNameResolver
{
/**
* @var string
* @see https://regex101.com/r/KphLd2/1
*/
private const BIG_LETTER_START_REGEX = '#^[A-Z]#';

/**
* @var array<string, string[]>
*/
Expand Down Expand Up @@ -174,7 +167,7 @@ private function resolveFromStmtsDocBlocks(array $stmts): array
static function ($node) use (&$shortNames) {
if ($node instanceof PhpDocTagNode) {
$shortName = trim($node->name, '@');
if (StringUtils::isMatch($shortName, self::BIG_LETTER_START_REGEX)) {
if (ucfirst($shortName) === $shortName) {
$shortNames[] = $shortName;
}

Expand Down

0 comments on commit b483230

Please sign in to comment.