rfc recursive return type definitions
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start with the recursive @return and @param examples in issue #9 and review the parser's existing type syntax. No file, test, or entry point is named. Done would require an agreed recursive type representation and corresponding parser behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
/**
* @return array<string, scalar|array<int, array<{{recursive definition is here}}>>>
*/
function DoThingWithNode(DOMNode $node) : array { /* do stuff here */ }
So I have this method that return an array with string keys whose values are either scalars or arrays with string keys whose values are either scalars or arrays with string keys whose values are either scalars with string keys..... etc.
If the definition stops at array, then one would just assume that phpstan et. al would determine that values at that level are "mixed" (or otherwise defined), which may be an undesirable effect.
One solution to the recursive @return/@param problem could be to define a class that encapsulates the recursion- i.e. class Thing extends ArrayObject & modify the return types to indicate scalar|Thing, but I'd be wanting to avoid class definitions.
A docblock-type solution would be to define a template/pattern tag so one could @thing foo array<string, scalar|array<string, {{@thing foo}}> , but I could foresee problems by virtue of it being a recursive solution to a recursive problem.
Thoughts?
p.s. the recursion here comes from the return type possibly containing arrays of the return type of the method, so maybe @return array<string, scalar|{{@method DoThingWithNode}}||{{@method DoSomeOtherThingWithNode}}> might be a solution by explicitly indicating the return values is built up from other methods ?
- Ngôn ngữ chính
- PHP
- Star
- 1.5k
- Fork
- 78
- Merge trung bình
- 9 giờ 5 phút
- Pull request đã merge (30 ngày)
- 5
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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/phpdoc-parser
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
phpstan/phpdoc-parser#317 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
phpstan/phpdoc-parser#281 · 2 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
phpstan/phpdoc-parser#271 · 1 bình luận · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
phpstan/phpdoc-parser#219 ·
-
Extension for custom tags Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
phpstan/phpdoc-parser#178 · 1 bình luận ·
Tất cả issue của phpstan/phpdoc-parser
Issue tương tự
-
jira-created
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
nunomaduro/phpinsights#745 ·
-
status/awaiting_triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
WordPress/plugin-check#1486 ·
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
az-digital/az_quickstart#6019 ·