MergePhpstanDocTagIntoNativeRector and RemoveUselessReturnTagRector removes return type that adds a clarification
Một pull request liên quan đã được merge.
- #8924 của @APX403 — đã 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
- 45/100
Hướng nghiên cứu
The bug is in the rules RemoveUselessReturnTagRector and MergePhpstanDocTagIntoNativeRector, which wrongly drop a conditional @phpstan-return tag on isListOfArrays. Start with the existing test fixtures for these two rules and add the reported method as a case where the tag must stay. Done when the snippet keeps its @phpstan-return tag and the rule tests pass.
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.8.3 |
The @phpstan-return that narrows down the return type of isListOfArrays gets wrongfully removed. Code that uses $data[0] after isListOfArrays now throws a PHPStan error: expects array<mixed>, mixed given.
Minimal PHP Code Causing Issue
/**
* @param array<mixed> $data
*
* @phpstan-return ($data is list<array> ? true : false)
*/
private function isListOfArrays(array $data): bool
{
return \array_is_list($data) && \array_all($data, static fn (mixed $item): bool => \is_array($item));
}
https://getrector.com/demo/bb2e87cf-253d-4aed-9bc4-25a4a6b2f6a0
Expected Behaviour
Do not remove the return type.
EDIT: Claude told me to use @phpstan-assert-if-true list<array<mixed>> $data instead, which doesn't get removed by rector.
- Ngôn ngữ chính
- PHP
- Star
- 10.5k
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rectorphp/rector
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
MyCLabsMethodCallToEnumConstRector should only refactor according to RuleDefinitionCó thể đã có người làm @samsonasik đã nhận 2 ngày trước. Đang mởbug
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 55/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
Tất cả issue của rectorphp/rector
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Author mapping step: "create new user" and "assign to existing user" fields have no spacing between themCó thể đã có người làm @umeshnevase đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
WordPress/wordpress-importer#275 ·
-
security/openvpn-legacy: read-only user can stop a running VPNCó thể đã có người làm @besendorf đã nhận hôm nay. Đang mởincomplete
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
opnsense/plugins#5887 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
jira-created
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100