Skip to content

Commit 71fe72d

Browse files
authored
[AutoImport] Skip conflict aliased with docblock on auto import (#6929)
1 parent 5d1b2c6 commit 71fe72d

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/AliasClassNameImportSkipVoter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function __construct(
2929
public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType, Node $node): bool
3030
{
3131
$aliasedUses = $this->aliasUsesResolver->resolveFromNode($node, $file->getNewStmts());
32+
$longNameLowered = strtolower($fullyQualifiedObjectType->getClassName());
3233
$shortNameLowered = $fullyQualifiedObjectType->getShortNameLowered();
3334

3435
foreach ($aliasedUses as $aliasedUse) {
@@ -38,6 +39,10 @@ public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedO
3839
if (\str_ends_with($aliasedUseLowered, '\\' . $shortNameLowered)) {
3940
return true;
4041
}
42+
43+
if ($aliasedUseLowered === $shortNameLowered && $longNameLowered === $shortNameLowered) {
44+
return true;
45+
}
4146
}
4247

4348
return false;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Rector\Tests\Issues\AutoImport\Fixture\DocBlock;
4+
5+
use InvalidArgumentException as IAE;
6+
7+
class ConflictAliasedWithDocblock
8+
{
9+
/**
10+
* @throws \InvalidArgumentException
11+
*/
12+
public function test(): void
13+
{
14+
}
15+
}
16+
17+
?>

0 commit comments

Comments
 (0)