Skip to content

Commit

Permalink
Bump rector/rector from 0.18.8 to 0.18.10 (#144)
Browse files Browse the repository at this point in the history
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
  • Loading branch information
dependabot[bot] and staabm authored Nov 18, 2023
1 parent 7f29f69 commit 86ba16d
Show file tree
Hide file tree
Showing 25 changed files with 165 additions and 270 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"php": ">=7.4",
"rector/rector": "0.18.8",
"rector/rector": "0.18.10",
"friendsofphp/php-cs-fixer": "3.38.2",
"redaxo/php-cs-fixer-config": "^1.0"
},
Expand Down
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,17 @@
},
{
"name": "phpstan/phpstan",
"version": "1.10.41",
"version_normalized": "1.10.41.0",
"version": "1.10.42",
"version_normalized": "1.10.42.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "c6174523c2a69231df55bdc65b61655e72876d76"
"reference": "fc2316508de5453140b5cb3d3f8683a33e92f26a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6174523c2a69231df55bdc65b61655e72876d76",
"reference": "c6174523c2a69231df55bdc65b61655e72876d76",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/fc2316508de5453140b5cb3d3f8683a33e92f26a",
"reference": "fc2316508de5453140b5cb3d3f8683a33e92f26a",
"shasum": ""
},
"require": {
Expand All @@ -344,7 +344,7 @@
"conflict": {
"phpstan/phpstan-shim": "*"
},
"time": "2023-11-05T12:57:57+00:00",
"time": "2023-11-17T15:26:57+00:00",
"bin": [
"phpstan",
"phpstan.phar"
Expand Down Expand Up @@ -547,17 +547,17 @@
},
{
"name": "rector/rector",
"version": "0.18.8",
"version_normalized": "0.18.8.0",
"version": "0.18.10",
"version_normalized": "0.18.10.0",
"source": {
"type": "git",
"url": "https://github.com/rectorphp/rector.git",
"reference": "374bab157a41f6849556edc53125f856eb6c1c8c"
"reference": "f36bc0a707fd8af301df5108740ce41f9db8eded"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/374bab157a41f6849556edc53125f856eb6c1c8c",
"reference": "374bab157a41f6849556edc53125f856eb6c1c8c",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/f36bc0a707fd8af301df5108740ce41f9db8eded",
"reference": "f36bc0a707fd8af301df5108740ce41f9db8eded",
"shasum": ""
},
"require": {
Expand All @@ -570,7 +570,7 @@
"rector/rector-phpunit": "*",
"rector/rector-symfony": "*"
},
"time": "2023-11-14T15:30:19+00:00",
"time": "2023-11-16T19:42:21+00:00",
"bin": [
"bin/rector"
],
Expand All @@ -594,7 +594,7 @@
],
"support": {
"issues": "https://github.com/rectorphp/rector/issues",
"source": "https://github.com/rectorphp/rector/tree/0.18.8"
"source": "https://github.com/rectorphp/rector/tree/0.18.10"
},
"funding": [
{
Expand Down
16 changes: 8 additions & 8 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '380bddae5f63eb2071f51663139e56706b83ded9',
'reference' => 'b070db1590810464ec1b5db978b799b126b36177',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '380bddae5f63eb2071f51663139e56706b83ded9',
'reference' => 'b070db1590810464ec1b5db978b799b126b36177',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -56,9 +56,9 @@
'dev_requirement' => false,
),
'phpstan/phpstan' => array(
'pretty_version' => '1.10.41',
'version' => '1.10.41.0',
'reference' => 'c6174523c2a69231df55bdc65b61655e72876d76',
'pretty_version' => '1.10.42',
'version' => '1.10.42.0',
'reference' => 'fc2316508de5453140b5cb3d3f8683a33e92f26a',
'type' => 'library',
'install_path' => __DIR__ . '/../phpstan/phpstan',
'aliases' => array(),
Expand Down Expand Up @@ -104,9 +104,9 @@
),
),
'rector/rector' => array(
'pretty_version' => '0.18.8',
'version' => '0.18.8.0',
'reference' => '374bab157a41f6849556edc53125f856eb6c1c8c',
'pretty_version' => '0.18.10',
'version' => '0.18.10.0',
'reference' => 'f36bc0a707fd8af301df5108740ce41f9db8eded',
'type' => 'library',
'install_path' => __DIR__ . '/../rector/rector',
'aliases' => array(),
Expand Down
Binary file modified vendor/phpstan/phpstan/phpstan.phar
Binary file not shown.
26 changes: 13 additions & 13 deletions vendor/phpstan/phpstan/phpstan.phar.asc
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmVHkT8ACgkQUcZzBf/C
5cAB/RAAg+/UhQeGwHvizVIm77Td9pluVpTgJt/7AM8FnovbiKm/CTpmeZ255qdO
IbViFFyM627WgeIB6cobNfBeDxjNuZSQKIfGwab2Q30CGI5WHNnRdTUwtMyq8kdb
biAz+fbU/bnB+ZAOpmPByxL+m8skWRT9CvvBOn06DK0798fLdF115F6FTUZLZIRg
B6owjK6ZW1GGmukAJp81Q5uM6nM4h4vqcmK1tSinDhixXA1H38jP4wIA6lrqthvV
CCsq9lKepQzJU85Ip464N9OMRrkYf9mh/6c735o59yHS0p26S+5gNYkeT4selXvx
zTq6wk1eB12FW6O0+Bn8V/lNy6BHK/MnAC/RFKPOJW2IOkKJjX4/MauRKrRa1gN6
K4kvYBuFdsg5zAbgpOAdLYoKP/qMP1CialgPrlOJo9nB8sNMRkU+BD9lphW7Jc6v
atzjU2H1xCKVqx1WL5XDBe4vZyVUaAEYfKp6tndTaa4Bi9ZR3BO94fNaxAVIn2Ai
YxC8mw4PVBGMpj/N66vQb6OturvngpACUlNuW3O+/ckj1CSw9QLXNS4pOwIbslL3
Xu58Xj0HE4W2Dd7UmjzDoidl+x1q50gSXzbrzORrI5jMan5McsTUm4HfTYTMnso5
ezoEIneuwXa8hoJqLdiX36Xlf/7K59W7sF2hPDXgaii7L9kN6aM=
=xFKI
iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmVXhiQACgkQUcZzBf/C
5cC2OA/+L/m+FL2H9UlerndJ6h+t/deEAXIeeUxIDzjyhY6+6Yuq1Qi6gvfEI/Uj
1PgyRzyyYjpvbdBJmU9ES3EiHOgkNfdA/IueggP+UNZqZ7J8V4qZHxi4RydAyYtM
PGwyt0uLbyQLS5uxaYbbIXOc3vyYK0dpimzJyKAltOvejBynHbb4JuJKbnlhv1de
kvChhqcDSbdWvzEgkauAI6c6VdLzXdm5xLQI82QpGpgsxjpPu9uaG8f+RUTffW/Y
y2b7pH4BNyMQFvgh5zNim8su8PliKg4U8KYa1hIggD0K/B9N8R1ib8N214omaSQr
kW1oKjFKHb8pi1znWcl2A6jEZlsmEkXM2Tm30AEWhW/AHTW0nREmGuqIHQTgfy1S
3rzpN61KjgR5jV2/sExorVaUM9gJayb0/oWmsv4K/aG0PpKBjtiakUpAmf7SkGJM
/dR9eL2VoyBYQugDaqDOeOoAqh2J00FVGsC+yH2hrH5xB49kiBJX6GSN4b9XmcVT
h1TvK74+VtbvhHngrBoG3wXKOVkqX0IL08EnJoYcLhrYpZmGfYiPHa3obzAJbwnm
TCjWUN/aN7nl0AGV/Hn2Vp+GcW+SKWtRNj9YpDVD2oXMzSAAr4e5yhh7jqYNjGEi
j+oga26zTYY2hxDjv7gfuFTFN0ARE3WNKYdeIzi1800uU/SPE0M=
=C2Kf
-----END PGP SIGNATURE-----
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use PhpParser\Node;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\ValueObject\Application\File;
use Rector\Naming\Naming\UseImportsResolver;
Expand Down Expand Up @@ -78,9 +78,9 @@ public function getUseImportTypesByNode(File $file, Node $node) : array
}
return $objectTypes;
}
public function hasImport(File $file, Name $name, FullyQualifiedObjectType $fullyQualifiedObjectType) : bool
public function hasImport(File $file, FullyQualified $fullyQualified, FullyQualifiedObjectType $fullyQualifiedObjectType) : bool
{
$useImports = $this->getUseImportTypesByNode($file, $name);
$useImports = $this->getUseImportTypesByNode($file, $fullyQualified);
foreach ($useImports as $useImport) {
if ($useImport->equals($fullyQualifiedObjectType)) {
return \true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Rector\Core\ValueObject\Application\File;
use Rector\Naming\Naming\AliasNameResolver;
use Rector\Naming\Naming\UseImportsResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockNameImporter;
final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPostRector
{
Expand Down Expand Up @@ -93,7 +92,7 @@ public function enterNode(Node $node) : ?Node
if ($firstStmt instanceof FileWithoutNamespace && \current($firstStmt->stmts) instanceof InlineHTML) {
return null;
}
if ($node instanceof Name) {
if ($node instanceof FullyQualified) {
return $this->processNodeName($node, $file);
}
if (!$node instanceof Stmt && !$node instanceof Param) {
Expand All @@ -114,9 +113,9 @@ public function enterNode(Node $node) : ?Node
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node);
return $node;
}
private function processNodeName(Name $name, File $file) : ?Node
private function processNodeName(FullyQualified $fullyQualified, File $file) : ?Node
{
if ($name->isSpecialClassName()) {
if ($fullyQualified->isSpecialClassName()) {
return null;
}
$namespaces = \array_filter($file->getNewStmts(), static function (Stmt $stmt) : bool {
Expand All @@ -127,39 +126,35 @@ private function processNodeName(Name $name, File $file) : ?Node
}
/** @var Use_[]|GroupUse[] $currentUses */
$currentUses = $this->useImportsResolver->resolve();
if ($this->classNameImportSkipper->shouldSkipName($name, $currentUses)) {
if ($this->classNameImportSkipper->shouldSkipName($fullyQualified, $currentUses)) {
return null;
}
$nameInUse = $this->resolveNameInUse($name, $currentUses);
$nameInUse = $this->resolveNameInUse($fullyQualified, $currentUses);
if ($nameInUse instanceof Name) {
return $nameInUse;
}
return $this->nameImporter->importName($name, $file);
return $this->nameImporter->importName($fullyQualified, $file);
}
/**
* @param Use_[]|GroupUse[] $currentUses
*/
private function resolveNameInUse(Name $name, array $currentUses) : ?\PhpParser\Node\Name
private function resolveNameInUse(FullyQualified $fullyQualified, array $currentUses) : ?\PhpParser\Node\Name
{
$originalName = $name->getAttribute(AttributeKey::ORIGINAL_NAME);
if (!$originalName instanceof FullyQualified) {
return null;
}
$aliasName = $this->aliasNameResolver->resolveByName($name, $currentUses);
$aliasName = $this->aliasNameResolver->resolveByName($fullyQualified, $currentUses);
if (\is_string($aliasName)) {
return new Name($aliasName);
}
return $this->resolveLongNameInUseName($name, $currentUses);
return $this->resolveLongNameInUseName($fullyQualified, $currentUses);
}
/**
* @param Use_[]|GroupUse[] $currentUses
*/
private function resolveLongNameInUseName(Name $name, array $currentUses) : ?Name
private function resolveLongNameInUseName(FullyQualified $fullyQualified, array $currentUses) : ?Name
{
if (\substr_count($name->toCodeString(), '\\') === 1) {
if (\substr_count($fullyQualified->toCodeString(), '\\') === 1) {
return null;
}
$lastName = $name->getLast();
$lastName = $fullyQualified->getLast();
foreach ($currentUses as $currentUse) {
foreach ($currentUse->uses as $useUse) {
if ($useUse->name->getLast() !== $lastName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ private function resolveNodesWithImportedUses(array $nodes, array $useImportType
$this->useImportsAdder->addImportsToNamespace($namespace, $useImportTypes, $constantUseImportTypes, $functionUseImportTypes);
return $nodes;
}
// just renamed no-namepaced class to namespaced class
$namespaces = \array_filter($nodes, static function (Stmt $stmt) : bool {
return $stmt instanceof Namespace_;
});
if ($namespaces !== []) {
// then add, to prevent adding + removing false positive of same short use
$this->useImportsAdder->addImportsToNamespace(\current($namespaces), $useImportTypes, $constantUseImportTypes, $functionUseImportTypes);
return $nodes;
}
// B. no namespace? add in the top
$useImportTypes = $this->filterOutNonNamespacedNames($useImportTypes);
// then add, to prevent adding + removing false positive of same short use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function addImportsToStmts(FileWithoutNamespace $fileWithoutNamespace, ar
$functionUseImportTypes = $this->diffFullyQualifiedObjectTypes($functionUseImportTypes, $existingFunctionUseImports);
$newUses = $this->createUses($useImportTypes, $constantUseImportTypes, $functionUseImportTypes, null);
if ($newUses === []) {
return $stmts;
return [$fileWithoutNamespace];
}
// place after declare strict_types
foreach ($stmts as $key => $stmt) {
Expand All @@ -67,14 +67,14 @@ public function addImportsToStmts(FileWithoutNamespace $fileWithoutNamespace, ar
\array_splice($stmts, $key + 1, 0, $nodesToAdd);
$fileWithoutNamespace->stmts = $stmts;
$fileWithoutNamespace->stmts = \array_values($fileWithoutNamespace->stmts);
return $fileWithoutNamespace->stmts;
return [$fileWithoutNamespace];
}
}
$this->mirrorUseComments($stmts, $newUses);
// make use stmts first
$fileWithoutNamespace->stmts = \array_merge($newUses, $stmts);
$fileWithoutNamespace->stmts = \array_values($fileWithoutNamespace->stmts);
return $fileWithoutNamespace->stmts;
return [$fileWithoutNamespace];
}
/**
* @param FullyQualifiedObjectType[] $useImportTypes
Expand Down
Loading

0 comments on commit 86ba16d

Please sign in to comment.