Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Juliette <[email protected]>
  • Loading branch information
rodrigoprimo and jrfnl authored Aug 21, 2024
1 parent d189e65 commit 168e746
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions WordPress/Docs/WP/GetMetaFunctionSingleParameterStandard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
<![CDATA[
When calling the `get_(comment|post|site|term|user)_meta()`, `get_metadata()`,
`get_metadata_default()`, and `get_metadata_raw()` functions, if the `$[meta_]key` parameter is
passed, the `$single` parameter should be passed as well to make it explicit what is the
expected return type.
passed, the `$single` parameter should be passed as well to make it explicit whether the functions should return a single value (the first value) or an array of values stored for the meta key.
]]>
</standard>
<code_comparison>
<code title="Valid: Get meta functions called either without the `$[meta_]key` parameter or with both the `$[meta_]key` and the `$single` parameters.">
<code title="Valid: Get meta functions called either without the `$[meta_]key` parameter; or with both the `$[meta_]key` and the `$single` parameters.">
<![CDATA[
$admin_color = get_user_meta(
$user_id,
Expand All @@ -22,7 +21,7 @@ $admin_color = get_user_meta(
$post_meta = get_metadata( 'post', $post_id<em></em> );
]]>
</code>
<code title="Invalid: Get meta function called with the `$[meta_]key` parameter and without `$single` parameter.">
<code title="Invalid: Get meta function called with the `$[meta_]key` parameter, but without the `$single` parameter.">
<![CDATA[
$admin_color = get_user_meta(
$user_id,
Expand Down
6 changes: 3 additions & 3 deletions WordPress/Sniffs/WP/GetMetaFunctionSingleParameterSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ final class GetMetaFunctionSingleParameterSniff extends AbstractFunctionParamete
/**
* List of functions this sniff should examine.
*
* Once support for PHP 5.4 is dropped, it is possible to create two private properties
* {@internal Once support for PHP < 5.6 is dropped, it is possible to create two class constants
* representing the two different signatures of get meta functions to remove the duplication
* of the name and position of the parameters.
* of the name and position of the parameters.}
*
* @link https://developer.wordpress.org/reference/functions/get_comment_meta/
* @link https://developer.wordpress.org/reference/functions/get_metadata/
Expand Down Expand Up @@ -172,7 +172,7 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p
$this->phpcsFile->addWarning(
'When passing the $%s parameter to %s(), it is recommended to pass the $%s parameter as well to make it explicit whether an array or a string is expected.',
$stackPtr,
'ReturnTypeNotExplicit',
'Missing',
$message_data
);
}
Expand Down

0 comments on commit 168e746

Please sign in to comment.