Check that `#[Covers]` targets exist

Đã đóng
#188 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Một pull request liên quan đã được merge.

  • #224 của @alies-dev — đã merge

Đá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
35/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
php
Lĩnh vực
testing

Hướng nghiên cứu

Read the plugin's afterClassLikeVisit or afterClassLikeAnalysis flow and compare the linked phpstan-phpunit rules and CoversHelper. Add tests for docblock targets and CoversMethod/CoversFunction string arguments, confirming they report undefined targets without marking them as used. A pull request is already open for this issue, so check its scope and tests before taking it on.

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

Mô tả

enhancement

@covers \App\Invoce (typo) or @covers ::totl is silently accepted. Attribute forms like #[CoversClass(Missing::class)] are already reported by Psalm as UndefinedClass, but docblock targets and the string arguments of #[CoversMethod]/#[CoversFunction] are not checked.

phpstan-phpunit checks docblock targets (ClassCoversExistsRule, ClassMethodCoversExistsRule, CoversHelper). It doesn't handle attributes yet (phpstan/phpstan-phpunit#289).

Idea: in afterClassLikeVisit/afterClassLikeAnalysis, resolve @covers/@coversDefaultClass targets and the method/function names in #[CoversMethod]/#[CoversFunction], and report UndefinedClass/UndefinedMethod/UndefinedFunction. This only validates targets; it must not mark them as used (see #141). Docblock @covers is ignored by PHPUnit 12. Roughly 80 lines with tests.

Idea borrowed from phpstan/phpstan-phpunit.

Ngôn ngữ chính
Gherkin
Star
79
Fork
38
Merge trung bình
3 giờ 54 phút
Pull request đã merge (30 ngày)
68

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 psalm/psalm-plugin-phpunit

Tất cả issue của psalm/psalm-plugin-phpunit

Issue tương tự

Thêm issue về Testing & QA

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.