Title: rfc recursive return type definitions · Issue #9 · phpstan/phpdoc-parser · GitHub
Open Graph Title: rfc recursive return type definitions · Issue #9 · phpstan/phpdoc-parser
X Title: rfc recursive return type definitions · Issue #9 · phpstan/phpdoc-parser
Description: /** * @return array
Open Graph Description: /** * @return array
X Description: /** * @return array<string, scalar|array<int, array<{{recursive definition is here}}>>> */ function DoThingWithNode(DOMNode $node) : array { /* do stuff here */ } So I have this m...
Opengraph URL: https://github.com/phpstan/phpdoc-parser/issues/9
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"rfc recursive return type definitions","articleBody":"```php\r\n/**\r\n* @return array\u003cstring, scalar|array\u003cint, array\u003c{{recursive definition is here}}\u003e\u003e\u003e\r\n*/\r\nfunction DoThingWithNode(DOMNode $node) : array { /* do stuff here */ }\r\n```\r\n\r\nSo 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.\r\n\r\nIf 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.\r\n\r\nOne solution to the recursive `@return`/`@param` problem could be to define a class that encapsulates the recursion- i.e. `class Thing extends ArrayObject` \u0026 modify the return types to indicate `scalar|Thing`, but I'd be wanting to avoid class definitions.\r\n\r\nA docblock-type solution would be to define a template/pattern tag so one could `@thing foo array\u003cstring, scalar|array\u003cstring, {{@thing foo}}\u003e` , but I could foresee problems by virtue of it being a recursive solution to a recursive problem.\r\n\r\nThoughts?\r\n\r\np.s. the recursion here comes from the return type possibly containing arrays of the return type of the method, so maybe `@return array\u003cstring, scalar|{{@method DoThingWithNode}}||{{@method DoSomeOtherThingWithNode}}\u003e` might be a solution by explicitly indicating the return values is built up from other methods ?","author":{"url":"https://github.com/SignpostMarv","@type":"Person","name":"SignpostMarv"},"datePublished":"2018-04-01T11:42:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/9/phpdoc-parser/issues/9"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:13226845-9a1e-e732-864b-9e276c068eec |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE80:E194E:17CAAB9:1F8BD65:696B846C |
| html-safe-nonce | 4f7e51854c1fbb2b42b5b3543b10994fe9f7afea57a8301e3e2b58eaf49ed6d2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTgwOkUxOTRFOjE3Q0FBQjk6MUY4QkQ2NTo2OTZCODQ2QyIsInZpc2l0b3JfaWQiOiI0NzE2NTUyMTUyMTQ4NTc1MzQwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | bd3ddfeaf7570f83a0e89584dc6a44b47a6f53f2f066f77037c42c061c6572ea |
| hovercard-subject-tag | issue:310317480 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/phpstan/phpdoc-parser/9/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b55d9c99fccd88c7a062d77aac25256cd42598a9073e1a284a7ac98c4cd80c02/phpstan/phpdoc-parser/issues/9 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b55d9c99fccd88c7a062d77aac25256cd42598a9073e1a284a7ac98c4cd80c02/phpstan/phpdoc-parser/issues/9 |
| og:image:alt | /** * @return array |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SignpostMarv |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/phpstan/phpdoc-parser git https://github.com/phpstan/phpdoc-parser.git |
| octolytics-dimension-user_id | 16435710 |
| octolytics-dimension-user_login | phpstan |
| octolytics-dimension-repository_id | 111290081 |
| octolytics-dimension-repository_nwo | phpstan/phpdoc-parser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 111290081 |
| octolytics-dimension-repository_network_root_nwo | phpstan/phpdoc-parser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width