Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#9,911 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
devtools

調査の方向性

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 はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rectorphp/rector のほかの issue

rectorphp/rector の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。