rfc recursive return type definitions
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
/**
* @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 ?
- 主要言語
- PHP
- スター
- 1.5k
- フォーク
- 78
- 平均マージ
- 9時間 5分
- マージ済み PR(30日)
- 5
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
phpstan/phpdoc-parser のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
phpstan/phpdoc-parser#317 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
phpstan/phpdoc-parser#281 · コメント 2 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
phpstan/phpdoc-parser#271 · コメント 1 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
phpstan/phpdoc-parser#219 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
phpstan/phpdoc-parser#178 · コメント 1 件 ·
phpstan/phpdoc-parser の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
a11y admissions.uiowa.edu needs grooming SiteImprove best practice
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
Save States Menu オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
pluginsGLPI/datainjection#673 ·