withImportNames() reports a change on a short name already imported next to a same-short-name alias
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
Direzione di ricerca
Look at NameImporter::resolveNameInUse() and NameImportingPostRector. The bug is about detecting a false positive change when a short name is already imported and a same-short-name alias appears later. Start by understanding the import resolution logic, then write a test with the provided minimal code to reproduce the issue. 'Done' means the file is not listed in changed_files on a dry-run when the output is identical.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.6.7, also on current main |
With withImportNames(), a class already used by its short name is reported as changed when another class with the same short name is imported under an alias after it.
The output is identical, but the file is counted as changed. With --dry-run it is never cached, so it is processed again on every run. With the aliased import first, nothing is reported.
Minimal PHP Code Causing Issue
namespace App;
use App\Dto\Response;
use App\Client\Response as ClientResponse;
final class SomeService
{
public function map(ClientResponse $clientResponse): Response
{
return new Response();
}
}
vendor/bin/rector process --dry-run --output-format=json lists the file under changed_files, with "changed_files": 0 in totals and NameImportingPostRector in changes, on every run.
NameImporter::resolveNameInUse() matches App\Client\Response as ClientResponse by its short name and returns Response, which is already what the code says.
Expected Behaviour
No change reported, the file is cached.
🤖 Drafted with AI assistance.
- Lingua principale
- PHP
- Stelle
- 10.4k
- Fork
- 742
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rectorphp/rector
-
FileCacheStorage uses copy() instead of rename(), corrupting cache files on parallel cold-cache runsApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
Tutte le issue di rectorphp/rector
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
521xueweihan/HelloGitHub#3790 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
benjaminkott/bootstrap_package#1670 ·
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni