Skip to content

Commit 3e787b9

Browse files
committed
wip
1 parent 692ea39 commit 3e787b9

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Tempest\Upgrade\Tempest2;
4+
5+
use PhpParser\Node;
6+
use PhpParser\NodeVisitor;
7+
use Rector\Rector\AbstractRector;
8+
9+
final class RemoveIdImportRector extends AbstractRector
10+
{
11+
public function getNodeTypes(): array
12+
{
13+
return [
14+
Node\UseItem::class
15+
];
16+
}
17+
18+
public function refactor(Node $node): ?int
19+
{
20+
if (! $node instanceof Node\UseItem) {
21+
return null;
22+
}
23+
24+
if ($node->name->toString() === 'Tempest\\Database\\Id') {
25+
return NodeVisitor::REMOVE_NODE;
26+
}
27+
28+
return null;
29+
}
30+
}

packages/upgrade/src/tempest2.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
use Rector\Renaming\Rector\Name\RenameClassRector;
55
use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector;
66
use Rector\Renaming\ValueObject\RenameProperty;
7+
use Tempest\Upgrade\Tempest2\RemoveIdImportRector;
78

89
return static function (RectorConfig $config) : void {
9-
$config->removeUnusedImports();
1010
$config->importNames();
1111
$config->importShortClasses();
1212

@@ -22,4 +22,6 @@
2222
newProperty: 'value'
2323
)
2424
]);
25+
26+
$config->rule(RemoveIdImportRector::class);
2527
};

0 commit comments

Comments
 (0)