functionMap: additions, improvement, corrections#127
Merged
szepeviktor merged 13 commits intophp-stubs:masterfrom Nov 2, 2023
Merged
functionMap: additions, improvement, corrections#127szepeviktor merged 13 commits intophp-stubs:masterfrom
szepeviktor merged 13 commits intophp-stubs:masterfrom
Conversation
johnbillion
reviewed
Nov 2, 2023
| 'stripslashes_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], | ||
| 'urldecode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], | ||
| 'urlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], | ||
| 'wp_clear_scheduled_hook' => ['(0|positive-int|($wp_error is false ? false : \WP_Error))', 'args'=>$cronArgsType], |
Contributor
There was a problem hiding this comment.
I wasn't aware PHPStan supported this syntax for conditional return types, nice
Contributor
Author
There was a problem hiding this comment.
Me neither. It's great! It helps to simplify some of the conditions and make them easier to read.
szepeviktor
approved these changes
Nov 2, 2023
| * @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output | ||
| * @phpstan-return ($output is 'ARRAY_A' ? array<string, string|int>|\WP_Error|null : ($output is 'ARRAY_N' ? list<string|int>|\WP_Error|null : \WP_Term|\WP_Error|null)) | ||
| */ | ||
| function get_term($term, $taxonomy = '', $output = \OBJECT, $filter = 'raw') |
Member
There was a problem hiding this comment.
core says: constant
phpstan says: string
viktor says: WordPress
define( 'OBJECT', 'OBJECT' );
Contributor
Author
There was a problem hiding this comment.
To be fair, core also says string but passes the default string as a constant. But yeah, define( 'OBJECT', 'OBJECT' ); is weird.
Member
|
Here it comes, a blind merge ... |
IanDelMar
added a commit
to IanDelMar/wordpress-stubs
that referenced
this pull request
Nov 4, 2023
* Improve return type of get_comment() and get_post() * Add wpdb::get_row() to functions map * Add tests for wp_clear_scheduled_hook() * Add wpdb::get_results() to the functions map * Add get_bookmark() to function map * Add get_category() to function map * Add argument type to get_term() * Use fully qualified name * Add get_category_by_path() to function map * Remove types already added without function map * Add spaces around array assignment operator * Regenerate function map * Add trailing comma to last array item
IanDelMar
added a commit
to IanDelMar/wordpress-stubs
that referenced
this pull request
Nov 4, 2023
IanDelMar
added a commit
to IanDelMar/wordpress-stubs
that referenced
this pull request
Nov 11, 2023
* Improve return type of get_comment() and get_post() * Add wpdb::get_row() to functions map * Add tests for wp_clear_scheduled_hook() * Add wpdb::get_results() to the functions map * Add get_bookmark() to function map * Add get_category() to function map * Add argument type to get_term() * Use fully qualified name * Add get_category_by_path() to function map * Remove types already added without function map * Add spaces around array assignment operator * Regenerate function map * Add trailing comma to last array item
IanDelMar
added a commit
to IanDelMar/wordpress-stubs
that referenced
this pull request
Nov 11, 2023
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Most of the PR deals with the
$outputargument and conditional return types handling$output ∈ {OBJECT, ARRAY_A, ARRAY_N}.Additions:
wpdb::get_row(),wpdb::get_results(),get_bookmark(),get_category()andget_category_by_path(). I added tests, but did not test each parameter variation or unions.