Skip to content

Commit

Permalink
Updated Rector to commit b88e910957a85adafd6fb75fbe50991b9ec871d1
Browse files Browse the repository at this point in the history
rectorphp/rector-src@b88e910 [Performance] Reduce alias lookup on UnusedImportRemovingPostRector (#6346)
  • Loading branch information
TomasVotruba committed Oct 2, 2024
1 parent a3f6293 commit 68c7b4d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '0c9edebe4e1ca753d5bbe99e5109378155e87dde';
public const PACKAGE_VERSION = 'b88e910957a85adafd6fb75fbe50991b9ec871d1';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-10-01 20:52:27';
public const RELEASE_DATE = '2024-10-02 16:56:58';
/**
* @var int
*/
Expand Down
19 changes: 0 additions & 19 deletions src/PostRector/Rector/UnusedImportRemovingPostRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ private function resolveUsedPhpAndDocNames($namespace) : array
$names = \array_merge($phpNames, $docBlockNames);
return \array_unique($names);
}
private function resolveAliasName(UseUse $useUse) : ?string
{
return $useUse->alias instanceof Identifier ? $useUse->alias->toString() : null;
}
/**
* @param string[] $names
*/
Expand All @@ -156,17 +152,13 @@ private function isUseImportUsed(UseUse $useUse, array $names, ?Name $namespaceN
if ($namespacedPrefix === '\\') {
$namespacedPrefix = $comparedName . '\\';
}
$alias = $this->resolveAliasName($useUse);
$lastName = $useUse->name->getLast();
$namespaceName = $namespaceName instanceof Name ? $namespaceName->toString() : null;
// match partial import
foreach ($names as $name) {
if ($this->isSubNamespace($name, $comparedName, $namespacedPrefix)) {
return \true;
}
if (\is_string($alias) && $this->isUsedAlias($alias, $name)) {
return \true;
}
if (\strncmp($name, $lastName . '\\', \strlen($lastName . '\\')) !== 0) {
continue;
}
Expand All @@ -179,17 +171,6 @@ private function isUseImportUsed(UseUse $useUse, array $names, ?Name $namespaceN
}
return \false;
}
private function isUsedAlias(string $alias, string $name) : bool
{
if ($alias === $name) {
return \true;
}
if (\strpos($name, '\\') === \false) {
return \false;
}
$namePrefix = Strings::before($name, '\\', 1);
return $alias === $namePrefix;
}
private function isSubNamespace(string $name, string $comparedName, string $namespacedPrefix) : bool
{
if (\substr_compare($comparedName, '\\' . $name, -\strlen('\\' . $name)) === 0) {
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@
},
{
"name": "illuminate\/container",
"version": "v11.25.0",
"version_normalized": "11.25.0.0",
"version": "v11.26.0",
"version_normalized": "11.26.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/illuminate\/container.git",
Expand Down Expand Up @@ -569,8 +569,8 @@
},
{
"name": "illuminate\/contracts",
"version": "v11.25.0",
"version_normalized": "11.25.0.0",
"version": "v11.26.0",
"version_normalized": "11.26.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/illuminate\/contracts.git",
Expand Down
Loading

0 comments on commit 68c7b4d

Please sign in to comment.