Skip to content

Commit df88764

Browse files
authored
[AutoImport] Skip used at @see on UnusedImportRemovingPostRector (rectorphp#7299)
1 parent 180d36c commit df88764

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

src/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,13 @@ public function getGenericTagClassNames(): array
455455
continue;
456456
}
457457

458+
// add default original value
459+
$resolvedClasses[] = $genericTagValueNode->value;
458460
if (! str_contains($genericTagValueNode->value, '::')) {
459-
$resolvedClasses[] = $genericTagValueNode->value;
460461
continue;
461462
}
462463

464+
// add resolved class name if any
463465
$resolvedClass = $genericTagValueNode->getAttribute(PhpDocAttributeKey::RESOLVED_CLASS);
464466
if ($resolvedClass === null) {
465467
$resolvedClasses[] = $genericTagValueNode->value;

src/BetterPhpDocParser/PhpDocParser/PhpDocTagGenericUsesDecorator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Rector\StaticTypeMapper\Naming\NameScopeFactory;
1616

1717
/**
18-
* Decorate node with fully qualified class name for generic annotations for @uses
18+
* Decorate node with fully qualified class name for generic annotations for @uses, @used-by, and @see
1919
* e.g. @uses Direction::*
2020
*
2121
* @see https://docs.phpdoc.org/guide/references/phpdoc/tags/uses.html
@@ -46,7 +46,7 @@ public function decorate(PhpDocNode $phpDocNode, PhpNode $phpNode): void
4646
return null;
4747
}
4848

49-
if (! in_array($node->name, ['@uses', '@used-by'], true)) {
49+
if (! in_array($node->name, ['@uses', '@used-by', '@see'], true)) {
5050
return null;
5151
}
5252

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
use src\Event\Infrastructure\API\GooglePlaces\Place;
4+
5+
final readonly class Location
6+
{
7+
/**
8+
* @param list<string> $types
9+
*/
10+
public function __construct(
11+
public array $types,
12+
) {}
13+
14+
/**
15+
* Returns true if the location is a city
16+
*
17+
* @see Place::isCity()
18+
*/
19+
public function isCity() : bool
20+
{
21+
return in_array('locality', $this->types, true);
22+
}
23+
}

0 commit comments

Comments
 (0)