Skip to content

Commit 40d67fd

Browse files
committed
[ci-review] Rector Rectify
1 parent 0f30cd9 commit 40d67fd

6 files changed

Lines changed: 12 additions & 12 deletions

File tree

rules/CodingStyle/ClassNameImport/ShortNameResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function resolveShortClassLikeNames(File $file): array
6666
$rootNode = $file->getUseImportsRootNode();
6767

6868
// nothing to resolve
69-
if (! $rootNode instanceof \PhpParser\Node) {
69+
if (! $rootNode instanceof Node) {
7070
return [];
7171
}
7272

src/Application/FileProcessor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ private function parseFileNodes(File $file, bool $forNewestSupportedVersion = tr
184184

185185
// wrap in FileNode to allow file-level rules
186186
$oldStmts = [new FileNode($oldStmts)];
187+
187188
$oldTokens = $stmtsAndTokens->getTokens();
188189

189190
$newStmts = $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file->getFilePath(), $oldStmts);

src/PhpParser/Node/FileNode.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Rector\PhpParser\Node;
66

7+
use PhpParser\Node;
78
use PhpParser\Node\Stmt;
89
use PhpParser\Node\Stmt\GroupUse;
910
use PhpParser\Node\Stmt\Namespace_;
@@ -21,7 +22,7 @@ public function __construct(
2122
public array $stmts
2223
) {
2324
$firstStmt = $stmts[0] ?? null;
24-
parent::__construct($firstStmt instanceof \PhpParser\Node ? $firstStmt->getAttributes() : []);
25+
parent::__construct($firstStmt instanceof Node ? $firstStmt->getAttributes() : []);
2526

2627
parent::__construct();
2728

@@ -32,6 +33,9 @@ public function getType(): string
3233
return 'CustomNode_File';
3334
}
3435

36+
/**
37+
* @return array<int, string>
38+
*/
3539
public function getSubNodeNames(): array
3640
{
3741
return ['stmts'];
@@ -40,15 +44,15 @@ public function getSubNodeNames(): array
4044
public function isNamespaced(): bool
4145
{
4246
foreach ($this->stmts as $stmt) {
43-
if ($stmt instanceof Stmt\Namespace_) {
47+
if ($stmt instanceof Namespace_) {
4448
return true;
4549
}
4650
}
4751

4852
return false;
4953
}
5054

51-
public function getNamespace(): ?Stmt\Namespace_
55+
public function getNamespace(): ?Namespace_
5256
{
5357
/** @var Namespace_[] $namespaces */
5458
$namespaces = array_filter($this->stmts, static fn (Stmt $stmt): bool => $stmt instanceof Namespace_);

src/PhpParser/Printer/BetterStandardPrinter.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ protected function p(
134134
: $content;
135135
}
136136

137-
protected function pCustomNode_File(FileNode $fileNode): string
138-
{
139-
return $this->pStmts($fileNode->stmts, true);
140-
}
141-
142137
protected function pExpr_ArrowFunction(ArrowFunction $arrowFunction, int $precedence, int $lhsPrecedence): string
143138
{
144139
if (! $arrowFunction->hasAttribute(AttributeKey::COMMENT_CLOSURE_RETURN_MIRRORED)) {

src/PostRector/Rector/ClassRenamingPostRector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use PhpParser\Node;
88
use PhpParser\Node\Stmt\Namespace_;
9-
use PhpParser\NodeTraverser;
109
use PhpParser\NodeVisitor;
1110
use Rector\CodingStyle\Application\UseImportsRemover;
1211
use Rector\Configuration\RenamedClassesDataCollector;

src/ValueObject/Application/File.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Rector\ValueObject\Application;
66

7+
use PhpParser\Node\Stmt\Namespace_;
78
use PhpParser\Node;
89
use PhpParser\Node\Stmt;
910
use PhpParser\Node\Stmt\InlineHTML;
@@ -156,7 +157,7 @@ public function addRectorClassWithLine(RectorWithLineChange $rectorWithLineChang
156157
* This node returns top most node,
157158
* that includes use imports
158159
*/
159-
public function getUseImportsRootNode(): Stmt\Namespace_|FileNode|null
160+
public function getUseImportsRootNode(): Namespace_|FileNode|null
160161
{
161162
if ($this->newStmts === []) {
162163
return null;
@@ -171,7 +172,7 @@ public function getUseImportsRootNode(): Stmt\Namespace_|FileNode|null
171172
// return sole Namespace, or none
172173
$namespaces = [];
173174
foreach ($firstStmt->stmts as $stmt) {
174-
if ($stmt instanceof Stmt\Namespace_) {
175+
if ($stmt instanceof Namespace_) {
175176
$namespaces[] = $stmt;
176177
}
177178
}

0 commit comments

Comments
 (0)