Skip to content

Commit

Permalink
[Renaming] Remove FileWithoutNamespace from getNodeTypes() on Rename…
Browse files Browse the repository at this point in the history
…NamespaceRector (#3475)
  • Loading branch information
samsonasik committed Mar 12, 2023
1 parent b66c8d3 commit 6cc0a40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use PHPStan\PhpDocParser\Ast\Node as DocNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\Naming\NamespaceMatcher;
use Rector\PhpDocParser\PhpDocParser\PhpDocNodeTraverser;
use Rector\Renaming\ValueObject\RenamedNamespace;
Expand All @@ -30,7 +29,7 @@ public function __construct(
* @param array<string, string> $oldToNewNamespaces
*/
public function renameFullyQualifiedNamespace(
Property|ClassMethod|Function_|Expression|ClassLike|FileWithoutNamespace $node,
Property|ClassMethod|Function_|Expression|ClassLike $node,
array $oldToNewNamespaces
): ?Node {
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
Expand Down
6 changes: 2 additions & 4 deletions rules/Renaming/Rector/Namespace_/RenameNamespaceRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use PhpParser\Node\Stmt\Use_;
use PhpParser\Node\Stmt\UseUse;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\Core\Rector\AbstractRector;
use Rector\Naming\NamespaceMatcher;
use Rector\NodeTypeResolver\Node\AttributeKey;
Expand All @@ -41,7 +40,6 @@ final class RenameNamespaceRector extends AbstractRector implements Configurable
Function_::class,
Expression::class,
ClassLike::class,
FileWithoutNamespace::class,
];

/**
Expand Down Expand Up @@ -82,12 +80,12 @@ public function getNodeTypes(): array
}

/**
* @param Namespace_|Use_|Name|Property|ClassMethod|Function_|Expression|ClassLike|FileWithoutNamespace $node
* @param Namespace_|Use_|Name|Property|ClassMethod|Function_|Expression|ClassLike $node
*/
public function refactor(Node $node): ?Node
{
if (in_array($node::class, self::ONLY_CHANGE_DOCBLOCK_NODE, true)) {
/** @var Property|ClassMethod|Function_|Expression|ClassLike|FileWithoutNamespace $node */
/** @var Property|ClassMethod|Function_|Expression|ClassLike $node */
return $this->docBlockNamespaceRenamer->renameFullyQualifiedNamespace($node, $this->oldToNewNamespaces);
}

Expand Down

0 comments on commit 6cc0a40

Please sign in to comment.