Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

withImportNames() reports a change on a short name already imported next to a same-short-name alias

Aperta
#9,911 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
devtools

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rectorphp/rector

Tutte le issue di rectorphp/rector

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.