Repository navigation
Commit 5dfb29c
authored
When `removeUnusedImports()` is enabled, UnusedImportRemovingPostRector
collects the class names used inside doc blocks through
PhpDocInfo::getGenericTagClassNames(). For generic tags such as @see,
@uses and @link it only registered the full tag value.
A tag like `@see Foo some description` therefore produced the single
candidate "Foo some description", which never matches the imported short
name "Foo". As a result the `use` import for Foo was considered unused
and removed, leaving an unresolved reference (or, for a class in another
namespace, one that silently resolves to the wrong class).
Per the phpDocumentor syntax `@see [FQSEN] [<description>]`, the class
reference is the leading token of the value. Register that leading token
in addition to the full value, so the import is correctly kept when a
description follows the class name.
1 parent 21785b4 commit 5dfb29c
3 files changed
Lines changed: 49 additions & 0 deletions
File tree
- src/BetterPhpDocParser/PhpDocInfo
- tests/Issues/NamespacedUse/Fixture
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
461 | 463 | | |
462 | 464 | | |
463 | 465 | | |
| 466 | + | |
464 | 467 | | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
465 | 479 | | |
466 | 480 | | |
467 | 481 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments