Skip to content

Commit

Permalink
Updated Rector to commit 1595e34d12d856eab8e2478de357f0b1dff3556f
Browse files Browse the repository at this point in the history
rectorphp/rector-src@1595e34 [CodingStyle] Refactor UseImportsAdder to return [FileWithoutNamespace] code on no namespaced code (#5254)
  • Loading branch information
TomasVotruba committed Nov 16, 2023
1 parent b4cef81 commit 1d5d0dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
7 changes: 1 addition & 6 deletions packages/PostRector/Rector/NameImportingPostRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,8 @@ private function processNodeName(Name $name, File $file) : ?Node
return null;
}
$namespaces = \array_filter($file->getNewStmts(), static function (Stmt $stmt) : bool {
return $stmt instanceof Namespace_ || $stmt instanceof FileWithoutNamespace;
return $stmt instanceof Namespace_;
});
// handle overlapped resolve last new stmts
// @see https://github.com/rectorphp/rector-src/pull/5251
if ($namespaces === []) {
return null;
}
if (\count($namespaces) > 1) {
return null;
}
Expand Down
6 changes: 3 additions & 3 deletions rules/CodingStyle/Application/UseImportsAdder.php
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
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 = '60047ce7785545401ad870d483060ce640fa3369';
public const PACKAGE_VERSION = '1595e34d12d856eab8e2478de357f0b1dff3556f';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-11-16 12:34:15';
public const RELEASE_DATE = '2023-11-16 21:49:13';
/**
* @var int
*/
Expand Down

0 comments on commit 1d5d0dd

Please sign in to comment.