auto-fix "Call to function in_array() requires parameter #3 to be set/true."
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Read the linked pull request #349 first; it already has this issue in progress. The issue describes the fixer behavior for in_array(), array_search() and eligible array_keys() calls, including named arguments, splat calls, and types inferred from PHPDoc. Done means only calls whose strict equivalence can be proven are changed, while base64_decode() and array_keys() calls without a search value remain unaffected.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
if we know native haystack and needle types for a in_array, array_keys or array_search call, it would be great we could fix add a true as 3rd parameter in case its missing or can always be true. we should only fix when haystacks' iterable type is a super type of needle (strict comparison). the fixer must not change calls where equivalence cannot be proven.
Example: in_array($needle, X::VALS) into its strict counterpart in_array($needle, X::VALS, true).
https://phpstan.org/r/e288cf2a-08e5-4c06-9255-1a98eefc99fe
named arguments should be supported and calls using the splat operator should be skipped.
we should not fix calls which get their iterable-value type from a phpdoc, e.g.:
/** @return int[] */
function getArray(): array {}
function doFoo(int $i):bool {
return in_array($i, getArray());
}
For array_keys(), only consider calls with at least two arguments, since the strictness flag matters only when a search value is supplied. Calls without a search value should remain unchanged.
The rule also reports calls to other functions, such as base64_decode(). Those calls should not be made fixable by this change.
- Ngôn ngữ chính
- PHP
- Star
- 714
- Fork
- 63
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 8
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
- Đọ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 phpstan/phpstan-strict-rules
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
phpstan/phpstan-strict-rules#317 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
phpstan/phpstan-strict-rules#316 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
phpstan/phpstan-strict-rules#298 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
phpstan/phpstan-strict-rules#283 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Rule about bitwise operatorĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
phpstan/phpstan-strict-rules#276 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của phpstan/phpstan-strict-rules
Issue tương tự
-
claude
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
sprain/sprainocchio#26 ·
-
sync-en
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
GSA/digital-gov-drupal#569 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
feature-request-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Codeinwp/wp-menu-icons#360 ·