Skip to content

Commit

Permalink
improve UseAnalyzerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Nov 5, 2021
1 parent 9b68637 commit 938dbc0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\NameImporting\NodeAnalyzer\UseAnalyzer\Fixture;

use Rector\Tests\CodingStyle\Rector\Use_\RemoveUnusedAliasRector\Source\AbstractInterface as BaseInterface;
use Rector\Tests\CodingStyle\Rector\Use_\RemoveUnusedAliasRector\Source\AbstractKernel as BaseKernel;

class SomeClass extends BaseKernel implements BaseInterface
{
public function run(BaseKernel $baseKernel): BaseInterface
{
$anotherBaseKernel = new BaseKernel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ public function provideData(): Iterator
new FullyQualified(FirstUsage::class),
New_::class,
];

yield [__DIR__ . '/Fixture/some_uses.php.inc', 'SomeUses', 0, new Identifier('SomeUses'), Class_::class];

yield [
__DIR__ . '/Fixture/use_import.php.inc',
'BaseKernel',
0,
new Identifier('BaseKernel'),
Node\Stmt\UseUse::class,
];
yield [
__DIR__ . '/Fixture/use_import.php.inc',
'BaseInterface',
0,
new Identifier('BaseInterface'),
Node\Stmt\UseUse::class,
];
yield [__DIR__ . '/Fixture/use_import.php.inc', 'SomeClass', 0, new Identifier('SomeClass'), Class_::class];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ final class RemoveUnusedAliasRectorTest extends AbstractRectorTestCase
*/
public function test(SmartFileInfo $fileInfo): void
{
dump($fileInfo->getRealPath());

$this->doTestFileInfo($fileInfo);
}

Expand Down
4 changes: 4 additions & 0 deletions rules/CodingStyle/Rector/Use_/RemoveUnusedAliasRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public function refactor(Node $node): ?Node
}

$this->resolvedNamesAndParentsByShortName = $this->useAnalyzer->resolveUsedNameNodes($searchNode);

dump(count($this->resolvedNamesAndParentsByShortName));
die;

$this->resolvedDocPossibleAliases = $this->docAliasResolver->resolve($searchNode);
$this->useNamesAliasToName = $this->useNameAliasToNameResolver->resolve($this->file);

Expand Down

0 comments on commit 938dbc0

Please sign in to comment.