From 1ff7cf63eb4a1056c12ed72a3f800b01692d8714 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 29 Nov 2022 01:11:22 +0100 Subject: [PATCH] WP/Capabilities: tiny tweaks * Use `$%s` to indicate a parameter name in an error message. * Consistently use multi-line array for `$data` parameter with multiple entries (as in: consistent with how this is done elsewhere in this same sniff). * Mark a remark about a lists which needs regular updates as `@internal`. --- WordPress/Sniffs/WP/CapabilitiesSniff.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/WordPress/Sniffs/WP/CapabilitiesSniff.php b/WordPress/Sniffs/WP/CapabilitiesSniff.php index 6ffc54f23c..b980be1d54 100644 --- a/WordPress/Sniffs/WP/CapabilitiesSniff.php +++ b/WordPress/Sniffs/WP/CapabilitiesSniff.php @@ -165,14 +165,15 @@ class CapabilitiesSniff extends AbstractFunctionParameterSniff { /** * List of known primitive and meta core capabilities. * - * To be updated after every major release. Sorted alphabetically. - * Last updated for WordPress 6.1.0. - * * Sources: * - {@link https://wordpress.org/support/article/roles-and-capabilities/ Roles and Capabilities handbook page} * - The `map_meta_cap()` function in the `src/wp-includes/capabilities.php` file. * - The tests in the `tests/phpunit/tests/user/capabilities.php` file. * + * List is sorted alphabetically. + * + * {@internal To be updated after every major release. Last updated for WordPress 6.1.0.} + * * @since 3.0.0 * * @var array All capabilities available in core. @@ -382,7 +383,11 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p 'Couldn\'t determine the value passed to the $%s parameter in function call to %s(). Please check if it matches a valid capability. Found: %s', $i, 'Undetermined', - array( $function_details['name'], $matched_content, $parameter['clean'] ), + array( + $function_details['name'], + $matched_content, + $parameter['clean'], + ), 3 // Message severity set to below default. ); return; @@ -408,7 +413,7 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p if ( empty( $matched_parameter ) ) { $this->phpcsFile->addError( - 'An empty string is not a valid capability. Empty string found as the %s parameter in a function call to %s()"', + 'An empty string is not a valid capability. Empty string found as the $%s parameter in a function call to %s()"', $first_non_empty, 'Invalid', array(