withImportNames() reports a change on a short name already imported next to a same-short-name alias
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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, 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.
- 主要言語
- PHP
- スター
- 10.4k
- フォーク
- 742
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rectorphp/rector のほかの issue
-
feature
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
rectorphp/rector の issue をすべて見る
似ている issue
-
sync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
UX
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ProfessionalWiki/NeoWiki#1573 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100