Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#9,911 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
devtools

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
10.4k
Fork
742
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rectorphp/rector

Tất cả issue của rectorphp/rector

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.