-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement WordPress-like documentations // Magic::argType()
#152
Comments
Thanks, sounds like a very good feature. I'll try to get to it within few weeks. |
Lol, there was actually almost identical format supported for ages: #37 I guess, I'll just tweak it a bit... |
Basic support released in 2020.04.22.001 One thing I could not figure out yet though, how do you describe an array of associative arrays with this format? Like:
Is this what you use the nested format you linked in the description for?
|
Yee. Something like that. There are some nested things but not documented in the "usual doc-comment" way. It is more like "See Yaba\Daba::doo()" which then describes the next level. For example: [ // see https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-query.php#L627
'author' => 'barney',
'meta_query' => [ // documented on line 664 it says: "See WP_Meta_Query." (meaning WP_Meta_Query::__construct() )
// from here on see https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-meta-query.php#L106
'relation' => 'AND',
[ // nested array as documented
'key' => 'bam',
'value' => 'BAM!',
],
[ // yes, there can be multiple
'key' => 'type',
'value' => 'comic',
],
'a-wild-key-appears' => [ // may have keys but this can be ignored I guess
'key' => 'year',
'value' => 'damn old',
],
] Hope this gives an insight on nesting. There are several references saying "See ..." so the nested array/structure is documented somewhere else. Fingers crossed that this is can be parsed, followed and appended to the deep-assoc-completion . Does that help / answer your question? |
Thanks. Sorry, looks like I misunderstood what you meant by "nesting". What I wanted to know was the official format WordPress uses to describe an array of arrays, but I guess I better just google this out myself. I did not initially grasp that by I could also possibly add support for some expectedArguments(WP_Query::parse_query(), 0, [
'meta_query' => Magic::argType(0, [WP_Meta_Query::class, '__construct']),
]); (though this would be still needed to be implemented on my part) |
We thought so too, but having a pattern or finding a well established could do so. The idea with .phpstorm.meta.php is absolutely charming, but needs a lot of hands on an will be carried around in millions of repositories all with the same content. But you could have this built-in: If you can provide a helper like the Would this be a way for you? |
Sounds great! Though I'll be able to get to it only in few weeks, when I'm not so busy with the vscode port |
Magic::argType()
As seen on https://cloud.githubusercontent.com/assets/5202330/26426602/0f72f554-40e2-11e7-8873-30b873310746.png this PHPStorm extension can make use of doc comments:
Of course there are different types of documenting an array:
Can you please support this one way of array-description too?
It would be loved by all WP devs I guess ;-)
more complex example:
https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-query.php#L664
Also note for the marked line:
Within the key 'meta_query' there is another structure nested that can be found here https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-meta-query.php#L106
This could be solved by following a "See WP_Meta_Query" keyword and parsing the constructor of this class. Methods may be referenced too (e.g. "See WP_Query::parse_query() for all" as shown in the image above ).
The text was updated successfully, but these errors were encountered: